# New blog: 🎄 Twelve Days of SMT 🎄 - Day 2: ValueToKey and ExtractField

**URL:** <https://forum.confluent.io/t/new-blog-twelve-days-of-smt-day-2-valuetokey-and-extractfield/341>\
**Category:** Kafka Connect\
**Created:** [9 December 2020 21:06 UTC](https://forum.confluent.io/t/new-blog-twelve-days-of-smt-day-2-valuetokey-and-extractfield/341 "2020-12-09T21:06:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [9 December 2020 21:06 UTC](https://forum.confluent.io/t/new-blog-twelve-days-of-smt-day-2-valuetokey-and-extractfield/341/1 "2020-12-09T21:06:27Z")

</div>

Setting the key of a Kafka message is important as it ensures correct logical processing when consumed across multiple partitions, as well as being a requirement when joining to messages in other topics. When using Kafka Connect the connector may already set the key, which is great. If not, you can use these two Single Message Transforms (SMT) to set it as part of the pipeline based on a field in the value part of the message.

To use the ValueToKey Single Message Transform specify the name of the field (id ) that you want to copy from the value to the key:

" transforms " : " copyIdToKey " ,

" transforms.copyIdToKey.type " : " org.apache.kafka.connect.transforms.ValueToKey " ,

" transforms.copyIdToKey.fields " : " id " ,

* * *

**Read more:** [🎄 Twelve Days of SMT 🎄 - Day 2: ValueToKey and ExtractField](https://rmoff.net/2020/12/09/twelve-days-of-smt-day-2-valuetokey-and-extractfield/)

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [9 February 2021 13:29 UTC](https://forum.confluent.io/t/new-blog-twelve-days-of-smt-day-2-valuetokey-and-extractfield/341/2 "2021-02-09T13:29:15Z")

</div>


