# Using HasCustomFields in a plugin

**URL:** <https://meta.discourse.org/t/using-hascustomfields-in-a-plugin/176469>\
**Category:** Development\
**Created:** [January 18, 2021, 5:50pm UTC](https://meta.discourse.org/t/using-hascustomfields-in-a-plugin/176469 "2021-01-18T17:50:53Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [January 18, 2021, 8:54pm UTC](https://meta.discourse.org/t/using-hascustomfields-in-a-plugin/176469/6 "2021-01-18T20:54:15Z")

</div>

Thanks so much! So  
`Server.new.custom_fields_fk` is `pfaffmanager_server_id` if I use `pfaffmanager_serfver_id`. So maybe I should use `server_id` and then override as you suggested above.

It looks like `refresh_custom_fields_from_db` is trying to use the wrong names. I don’t quite understand what `_custom_fields.order...` is doing.

> <https://github.com/discourse/discourse/blob/main/app/models/concerns/has_custom_fields.rb#L276-283>

I’m going to see what happens if I use `server_id` and if I can then override `custom_fields_fk`

---

_[View the full topic](https://meta.discourse.org/t/using-hascustomfields-in-a-plugin/176469)._
