# How to add custom field to topic?

**URL:** <https://meta.discourse.org/t/how-to-add-custom-field-to-topic/57948>\
**Category:** Development\
**Created:** [25. Februar 2017 um 16:46 UTC](https://meta.discourse.org/t/how-to-add-custom-field-to-topic/57948 "2017-02-25T16:46:16Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)\
**Post date:** [7. März 2017 um 19:43 UTC](https://meta.discourse.org/t/how-to-add-custom-field-to-topic/57948/4 "2017-03-07T19:43:41Z")

</div>

Thanks. It worked. But still … the value in setter function is always null. Could you point me in a right direction with

```
Topic.update(topic, props);

```

How should custom\_fields.bumped\_at\_with\_button be passed to props in order to be saved?

I’ve tried something, but it doesn’t work ☹ In following code only bumped\_at get’s saved to database… and sadly no new record in topic\_custom\_fields table.

```
import Topic from 'discourse/models/topic';

export default {
  actions: {
    clickButton(topic) {
      const current_date = new Date();
      topic.set('bumped_at', current_date);
      topic.set('custom_fields.bumped_at_with_button', current_date);
      const props = topic.getProperties('bumped_at', 'custom_fields');
      Topic.update(topic, props);
    }
  }
};

```

---

_[View the full topic](https://meta.discourse.org/t/how-to-add-custom-field-to-topic/57948)._
