# Getting Category's custom field value from Topic

**URL:** https://meta.discourse.org/t/getting-categorys-custom-field-value-from-topic/56571
**Category:** Development
**Created:** [30 januari 2017 om 07:59 UTC](https://meta.discourse.org/t/getting-categorys-custom-field-value-from-topic/56571 "2017-01-30T07:59:08Z")
**Posts on this page:** 5
**Page:** 1

<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: [30 januari 2017 om 07:59 UTC](https://meta.discourse.org/t/getting-categorys-custom-field-value-from-topic/56571/1 "2017-01-30T07:59:08Z")

</div>

I have created custom category field enable\_bump\_topic (by example of @SamSaffron’s discourse-solved plugin). But I don’t seem to get how could I access this custom field when on Topic. I created canBump computed property for Topic ([discourse-bump-topic/assets/javascripts/discourse/initializers/extend-topic-for-bump-button.js.es6 at master · jannolii/discourse-bump-topic · GitHub](https://github.com/jannolii/discourse-bump-topic/blob/master/assets/javascripts/discourse/initializers/extend-topic-for-bump-button.js.es6)) but I only get value out from Category’s custom field when I first visit Category and open Edit form and then go to this Categroy’s topic. If I go directly to Topic I get undefined when try to access custom\_fields. It’s like custom\_fields doesn’t exist before I go and look at the Category settings.

What am I missing? What am I not getting?

My (still very raw) project: [GitHub - jannolii/discourse-bump-topic · GitHub](https://github.com/jannolii/discourse-bump-topic)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [30 januari 2017 om 13:54 UTC](https://meta.discourse.org/t/getting-categorys-custom-field-value-from-topic/56571/2 "2017-01-30T13:54:14Z")

</div>

You need to add it to the serializer of the page you want it to be, or make an additional request to an endpoint that will give you this value.

---

<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: [30 januari 2017 om 14:33 UTC](https://meta.discourse.org/t/getting-categorys-custom-field-value-from-topic/56571/3 "2017-01-30T14:33:34Z")

</div>

Thanks. Could there be an example where custom field is being added to a serializer? Quick scan didn’t reveal such thing being used in some popular plugins

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [30 januari 2017 om 14:36 UTC](https://meta.discourse.org/t/getting-categorys-custom-field-value-from-topic/56571/4 "2017-01-30T14:36:03Z")

</div>

> <https://github.com/xfalcox/discourse-signatures/blob/master/plugin.rb#L20-L26>

Here code it’s adding a new field to the post serializer. You need something similar, but adding a new field to the topic serializer I think.

---

<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: [30 januari 2017 om 16:42 UTC](https://meta.discourse.org/t/getting-categorys-custom-field-value-from-topic/56571/5 "2017-01-30T16:42:24Z")

</div>

Thanks a lot! Now I’m starting to get somewhere 😉
