How can I change the value of a custom field via post function
Asked by Tim H_:

I have a custom field called "Region" with list values (A, B, C for the sake of simplicity). Now I want to achieve this: Whenever I execute a certain transition, e.g. "Delegate to Region A", the value of the field should change to "A".

I'm using Jira Service Management Data Center and would like to use a post function for this. I can select the post function "Update issue field". However, I don't see "Region" in the dialogue. Any ideas?

Probably, I could use automation rules. But I would prefer to use post functions as automation rules would affect all workflows and not only this specific ones. I think, automation rules are a bit error prone.

Any help is greatly appreciated!


Answers:
author: Suprija Sirikonda _Appfire_
body: Hi [@Tim H_](/t5/user/viewprofilepage/user-id/519831) ,

If you've the [Jira Misc Workflow Extensions (JMWE) app](https://marketplace.atlassian.com/apps/292/jira-misc-workflow-extensions-jmwe?tab=overview&hosting=datacenter) installed in your Server/DC instance, you can achieve your requirement by following below steps:

1. Add [JMWE Set issue fields post-function](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461996276/Set+issue+fields) on the desired transition (Ex: Delegate to Region A) of the workflow.
2. Select "Region" for "Add field"
3. Add the desired value

BTW, I'm from Appfire, the vendor of JMWE app.

Regards,

Suprija \| Appfire

comments: author: Nigel Jewell
body: Hi Suprija. Is there a way to set a field as part of a custom script, not using the "set issue fields" function? Something like ...

```
{%if condition %}
   issue.fields.customfield_13747 = "123"
{%endif%}
```

?


author: John Funk
body: Hi Tim,

1. What kind of field specifically is the Region field?

2. Do other fields of the same type show up?

3. Is there anything in the Context for the field that would make it not show up for that workflow? i.e. the workflow is attached to an issue type that is not included in the Context

4. You can put conditions in Automation rules so that not all workflows would be subjected to the rule.

5. Can you explain more about how automation rules are a bit error prone? That's not been my experience.

comments: author: Tim H_
body: Hi John,

thanks for your reply!

1. It is a list of predefined text values, one of which hast to be selected.

2. Custom fields generally don't show up. Only several system fields as well as three fields that have something to do with the estimated time for a solution.

3. The field is defined for (and used in) the project. Other fields with a similar configuration don't shop up as well. Neither do fields that have a global context.

4. Thanks. I know that, but I fear that this may become very complicated. Especially when I have more and more automation rules.

5. I fear that I could lose track on all those rules. So, the rule automation would not be error-prone per se. But \*my configuration\* could be error prone, to be more precise. Also, rules don't take immediate effect. Sometimes, a refresh is needed. That's could confuse the agents.

Again, thank you very much for your suggestions and clarifications!


author: Tim H_
body: [@John Funk](/t5/user/viewprofilepage/user-id/7148) Any ideas how to solve this?

I implemented an automation rule as a workaround. However, as expected there are some side effects. The rule is executed in situations in which it shouldn't have been. I may be able to add some conditions to the rule, but actually a post function would exactly be what I need.


author: John Funk
body: You are probably going to need an add-on then for the workflows to get the field to be available. Something like JMWE or ScriptRunner.

If you want to post the automation rule here for review and suggestions on the conditions, feel free.


Tags: custom-field

data-center

jira-service-management

post-function