Assistance with automation to add custom field values from Epics to Initiatives in Jira Cloud
Asked by Maria Savignano:

I need to create an automation that checks a custom multi-select field that is present in both the Epic and the Initiative. The automation needs to work as follows:  
If a value is added to the custom field, let's call it customfield_1, it should check if the value is present in the Initiative, and if it's not, it should add it.  
I tried creating the automation by copying the field from the Epic to the Initiative, but it doesn't work because there are Epics associated with the Initiative that have different values in that field. The idea behind this is to ensure that the Initiative's field collects all the values from the associated Epics.

I used the component: Edit Issue and in the advanced option, I put the following JSON:

{  
"update": {  
"customfield_1": \[  
{  
"add": {  
"value": "{{issue.fields.customfield_1}}"  
}  
}  
\]  
}  
}

But this way it gives an error: (The value 'Xx, XX' is not valid for customfield_1) and the specified options are valid.

We tried modifying the rule using a lookup table with smart values, but it doesn't work, as it clears the value of the field in the Initiative and replaces it with the value from the Epic that was just linked.

Does anyone have any ideas on how I could achieve this?

Thanks in advance!


Answers:
author: Trudy Claspill
body: Hello [@Maria Savignano](/t5/user/viewprofilepage/user-id/5425533)

Can you please share with us images that show your entire Automation Rule? Sometimes the problem is related to the context in which the step is executing, and we can't discern that without seeing the entire rule.

I suspect there may be multiple problems:

1. You said the field is a multiple selection field. The way your JSON is written you are referencing the entire field with all its values. That is not the correct syntax to get just one value added to the multiple selection field.

2. If the JSON you have written is trying to add a value from one issue to another issue, the syntax is likely not correct for referencing the value from the source issue (the Epic?). But we can't tell you the correct syntax without seeing your entire rule to be able to determine the context in which the step is executing.

comments: author: Maria Savignano
body: Hello [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011)

I've tried creating the automation in many ways:

![2024-06-04_08h02_23.png](https://community.atlassian.com/t5/image/serverpage/image-id/327700iA08CAA32A46AE4C3/image-size/large?v=v2&px=999 "2024-06-04_08h02_23.png")![2024-06-04_08h18_48.png](https://community.atlassian.com/t5/image/serverpage/image-id/327701i0E0229784E7C3719/image-size/large?v=v2&px=999 "2024-06-04_08h18_48.png")

But it doesn't work as I expect :(


author: Trudy Claspill
body: Hello [@Maria Savignano](/t5/user/viewprofilepage/user-id/5425533)

Looking at just the second rule image you provided:

```
Trigger:?the value for Responsible Area is changed

Condition: Project = DID

Condition:?There are linked incidents present: 
  Types: is part of

Branch: For Linked incidents
  Types: is part of

  Edit incident fields
```

First I would recommend that you might want to add a condition after the trigger to check that the rule has been triggered by the value being changed in an Epic type of issue.

Second, are the Epic and the Initiative related through generic issue linking, or is the Epic a child issue of the Initiative? The way the rule is written it is looking at the generic issue link type of relationship rather than the parent/child relationship that is available with the Premium subscription if you have extended the Issue Type Hierarchy.

Third, in the JSON code are you trying to update the linked issues with data from the issue that triggered the rule? If so then the code is definitely incorrect.

And finally, I need clarification about what you are intending to do. In your JSON you have referenced "customfield_1", but in all other places you have referenced the field "Area Responsable". Is the "Area Responsable" field the one you are trying to update with your JSON code, or is the JSON code for updating a different field?


author: Maria Savignano
body: Hi [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011) I'm responding to your questions:

<br />

2. The Epic and Initiative are related through generic issue links. We don't have premium subscription.  
3. Yes, I want to copy the value of the field "?rea de Soporte" from the Epic (the issue that triggered the rule) to the linked Initiative. What would be the correct JSON?  
4. Yes, customfield_1 corresponds to the "?rea de Soporte" field. It's not actually named customfield_1; I used that name because I couldn't remember the exact field number for "?rea de Soporte" at the time of taking the screenshot.


Tags: automation

cloud

epic

initiative

jira-cloud

jira-service-management

jira-service-management-cloud