Set a "default default value (sic)" for a Forge custom field type

Dear Community,

I have a Custom Field Type developed in Forge. I would like to make sure that whenever someone creates a new Custom Field of this type, its default value is automatically set to a preset string. How is this possible to achieve?

Many thanks,
Peter

Hi @PeterVelosy,

You can use REST API to set default value for custom field:

Best regards,
Łukasz

Hi Łukasz,

I’ve tried this but I didn’t seem to be able to automate it with Forge. I created a trigger for the field creation event where I tried setting a default value to the newly created field right away, but it seemed to me that at the time the trigger fired, the new field hadn’t been created yet. As far as I remember, I got a HTTP 404 when trying to set a default value on this field. Is this the expected behavior? Can I somehow fire a trigger right after a new custom field (instance) has been created?

Hi @PeterVelosy,

The API for setting default values requires context of the custom field. Therefore, I believe, you should listen to the avi:jira:created:field:context event:
https://developer.atlassian.com/platform/forge/events-reference/jira/#custom-field-context-events

Best regards,
Łukasz