How to extract and copy common values from two user picker custom fields into a new field?
Asked by Jakeer:

Hello Team,

We have created Two User picker custom fields and added agents in it. Where Custom Field 1 has values A, B, C and Custom Field 2 has values A, B, C, D, E, F. Since A, B, C are the common values those values need to be copied into a new user picker custom field. How can we achieve this requirement,

Any quick suggestions will be more helpful.

Thanks,


Answers:
author: Kalyan Sattaluri
body: Hello [@Jakeer](/t5/user/viewprofilepage/user-id/5437123)

I just tested and it worked for me so I am not sure whats wrong with your set up.

Only thing I notice is that in your edit issue section, you are unncessarily choosing a field..

Nothing should be selected in the "Choose fields to set".. Only the advanced section should be set.

It should be like below screenshot.. notice I have no fields selected.. you have choosen "JSMField" in that dropdown.. we dont need to do that..

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/318638iE05C036E658D1FCB/image-size/large?v=v2&px=999 "image.png")


author: Kalyan Sattaluri
body: Hello [@Jakeer](/t5/user/viewprofilepage/user-id/5437123)

Are you asking how to do this using Automation or using script execution? Not clear from your post/..

comments: author: Jakeer
body: Hello [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

Sorry for not explaining in detail.

We need this through Automation rule.

Thanks,


author: Kalyan Sattaluri
body: Hello [@Jakeer](/t5/user/viewprofilepage/user-id/5437123)

What will be your trigger? Manual or Field Change? Or something else.

Lets assume its either Manual or Field change. (otherwise it gets complicated)

You do Advanced Branching after trigger to compare 2 fields and if value exists, update the third.

Lets assume your 3 fields are customfield_1000 , customfield_1001, customfield_1002.

where

* customfield_1000 has A, B,E
* customfield_1001 has A, C, D, E
* And you want to store A, E in customfield_1002

Steps:

* After your trigger,
* you do advanced branch, choose one of the fields to iterate, give it a name,(for ex "myagents")
* then in next step, if condition -\> advance compare -\> smart value, check if the value is present in other field, (see screenshot, notice what we are checking against and implement the same way)
* if so, add it to other (customfield_1003)field using advanced edit using below JSON:

{  
"update": {  
customfield_1003" : \[  
{  
"add": {  
"id":"{{myagent}}"  
}  
}  
\]  
}  
}

I havent tested this because I dont have this many fields, please see screenshot, implement and share your rule and audit log section to review.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/317016i324EB0D099664797/image-size/large?v=v2&px=999 "image.png")

Your Edit issue should use advanced Edit like below:

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/317018i4045B0D3B3254D93/image-size/large?v=v2&px=999 "image.png")


author: Jakeer
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

Good Morning!

Thanks for your help.

I have tried the automation rule you sent and the rule is not working as expected.

I have created an automation rule where is copied the Assignee Group Values into "User in groups" Custom field and Organization values into "User in Organizations" custom field.

Such that the values in User in Groups= Jakeer and Malisha if Assignee Group = L1 helpdesk

Values in User in Organizations = Malisha if Organization = HSBC

The common values present in the two custom fields are getting copied with the automation you provided. If both the members are in both the custom fields User in Groups and User in organizations then the values are not getting copied only one value either Jakeer or Malisha name is getting copied in the new field "myagents"

With the Automation rule you described I have tried and when i change the values the names are not getting changed although they are not part of assignee group or Grouporganization their names are remained same without changes in the field.

Regards,


author: Jakeer
body: ![04092024.png](https://community.atlassian.com/t5/image/serverpage/image-id/317136iBE2139BC2E7FC032/image-size/large?v=v2&px=999 "04092024.png")


author: Jakeer
body: I have shared the screenshot where i am not part of Organization still my name sowing after changing the values.

Also If Jakeer and Malisha both are part of both the fields then both the names are not getting copied in the customfields-3


author: Jakeer
body: ![09042024.png](https://community.atlassian.com/t5/image/serverpage/image-id/317155i3C293E4250A318B7/image-size/large?v=v2&px=999 "09042024.png")


author: Jakeer
body: In the above screenshot both the values are present in both the custom fields still only one value copied in the customfield-3 which is myagents field.


author: Kalyan Sattaluri
body: Hello [@Jakeer](/t5/user/viewprofilepage/user-id/5437123)

You need to share with me the detailed screenshots of the rule you have written including audit logs. Unless you share those, I cannot tell anything.

Again, I need screenshots of your advanced branch, your if condition, your edit issue and audit log of the run.


author: Jakeer
body: Hello [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

Sorry for the late response.

Please find the attached screenshots of the automation rule.![04122024-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/317918iA09BA2DE5C0E5FAA/image-size/large?v=v2&px=999 "04122024-1.png")![04122024.png](https://community.atlassian.com/t5/image/serverpage/image-id/317919i978B04057D30F7E2/image-size/large?v=v2&px=999 "04122024.png")![04122024-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/317920i5C83318AAEA60E6F/image-size/large?v=v2&px=999 "04122024-2.png")![04122024-4.png](https://community.atlassian.com/t5/image/serverpage/image-id/317921i7A70F22B4CEE885E/image-size/large?v=v2&px=999 "04122024-4.png")![04122024-3.png](https://community.atlassian.com/t5/image/serverpage/image-id/317922i1540F50574E3FFBC/image-size/large?v=v2&px=999 "04122024-3.png")

Thanks,


author: Jakeer
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

I am using the above automation rule to separate the agents who belongs to User in Groups as well as User in Organizations.

If in User in Groups = A, B, C, D,E

If in User in Organization = A,C,E

Then in myagents = A,C,E

But the above rule is not working as expected, it is randomly taking values although if they are not part of User in Groups as well as User in Organizations.

Can you plz look into it.


author: Jakeer
body: ![Result-04122024.png](https://community.atlassian.com/t5/image/serverpage/image-id/317932iAEB85DF084455559/image-size/large?v=v2&px=999 "Result-04122024.png")![Auditlog04122024-.png](https://community.atlassian.com/t5/image/serverpage/image-id/317933i027EACB29A527E46/image-size/large?v=v2&px=999 "Auditlog04122024-.png")

Here in User in Groups and User in Organizations you can see that Jakeer and Malisha are part but in my agents you can see only one name got copied.

Thanks,


author: Kalyan Sattaluri
body: Hello [@Jakeer](/t5/user/viewprofilepage/user-id/5437123)

Is customfield_10080 called myagents? Can you rename that field to something else?

Also, in the last step, you can remove updating the "Approvers" field, unless you want that.

If you cannot rename customfield_10080 to something else, you need to rename the variable from myagents to something else and update your if condition and also the last step where in advanced edit you are referencing {{myagents}}. replace every where in the rule where the variable is being referenced with the new variable name..

So do either of the steps, retrigger the rule and share the log once again,


author: Jakeer
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

I have made the changes mentioned and in the result i am getting error.![04122024-error.png](https://community.atlassian.com/t5/image/serverpage/image-id/318005iA5C710E50375C488/image-size/large?v=v2&px=999 "04122024-error.png")

Please find the attached logs screenshot.

Thanks,


author: Kalyan Sattaluri
body: What is the customfield_10080 field called?

Is it approvers?

Also what change have you made? Did you change the variable name? If so, share with me the screenshot of where variable is being defined in advanced branch and also edit issue screen.


author: Jakeer
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

customfield_10080 is the field name myagents.

![JSMField.png](https://community.atlassian.com/t5/image/serverpage/image-id/318017i83844FEF70726D43/image-size/large?v=v2&px=999 "JSMField.png")

Please find the attached screenshot.

Thanks,


author: Jakeer
body: ![edit.png](https://community.atlassian.com/t5/image/serverpage/image-id/318018i66904943FC797A08/image-size/large?v=v2&px=999 "edit.png")


author: Kalyan Sattaluri
body: Remove the highlighted section below from edit/issue in your rule and retrigger and let me know what you observe

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/318020iB39AFA05EE7ED117/image-size/large?v=v2&px=999 "image.png")


author: Jakeer
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

I have tried the same way mentioned still getting error.

![error.png](https://community.atlassian.com/t5/image/serverpage/image-id/318022i01365877D286283A/image-size/large?v=v2&px=999 "error.png")


author: Jakeer
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

Is there any update on my requirement?

Thanks


author: Jakeer
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

Can you help me if it is possible through script in jira cloud.

If Assignee Group = L1heldesk

If Group(Organization) = HSBC then in

User in Groups = The all members present in L1helpdesk should be copied in this field.

User in Organizations= The all members present in HSBC should be copied in this field.

Finally the common members in User in Groups and User in Organizations needs to be copied in "myagents" field.

Thanks,


author: Kalyan Sattaluri
body: Jakeer, First share with me the Edit issue screenshot again. That error means we are trying to update the same field in multiple places. And we need to remmove references to that field. So share screenshot to resolve that issue firts.


author: Jakeer
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

Please find the attached screenshot of my edit issue.

![edit issue.png](https://community.atlassian.com/t5/image/serverpage/image-id/318588i9EF3E886C93221CE/image-size/large?v=v2&px=999 "edit issue.png")

Thanks,


author: Kalyan Sattaluri
body: Hello, in the drop down "Choose fields to set", unselect the field "myagents"..

It should just be the advanced section...

see below screenshot and rerun the rule and share audit log.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/318592i3F8DE551F6BE4934/image-size/large?v=v2&px=999 "image.png")


author: Jakeer
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

After making the changes the automation showing errors and the audit log screenshot is shared below.

![Result1.png](https://community.atlassian.com/t5/image/serverpage/image-id/318608i16C69BB78C8D4C91/image-size/large?v=v2&px=999 "Result1.png")

Thanks,


author: Kalyan Sattaluri
body: Jakeer,

I want you to do 2 things:

1) In the advanced edit, you need to change {{myagents}} to {{JSMField}} .. right now you are trying to edit field with itself. See screenshot where I am referring to.

2) Insert a new log statement above where you are logging {{JSMField}} and log {{User in Organizations}} .

Do both, rerun the rule and share audit log.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/318615iE33007EA3AB2A8AC/image-size/large?v=v2&px=999 "image.png")


author: Jakeer
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

I made the changes mentioned above, in result automation is showing success.

But the values are not getting copied exactly.

If in User in Groups= A, B,C,D

If in User in Organizations = A,C,D

Common values are A,C,D But only A, D are getting copied if i refresh then A, C are getting copied then after i remove all values and refresh then all the values are getting copied.

![new-.png](https://community.atlassian.com/t5/image/serverpage/image-id/318620i3DBA3ED7B5ACA169/image-size/large?v=v2&px=999 "new-.png")

Thanks,


author: Jakeer
body: Hi,

You can see the result.

![common.png](https://community.atlassian.com/t5/image/serverpage/image-id/318622iC07FF6CBF50BF414/image-size/large?v=v2&px=999 "common.png")


author: Kalyan Sattaluri
body: Can you select the "For Each smart value" and share the screenshot. I need to see both the steps and For Each details section together like in below screenshot..

I \*think\* I know the issue and we may have to store these values teemporarily before we update.. but yes, please select For Each and share with me the screen shot..

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/318624i9E0732593BAF4C2C/image-size/large?v=v2&px=999 "image.png")


author: Jakeer
body: Hi,

Please find the screenshot.

![jsm.png](https://community.atlassian.com/t5/image/serverpage/image-id/318627iE50AC5B3ED0BCF7C/image-size/large?v=v2&px=999 "jsm.png")

Thanks,


author: Kalyan Sattaluri
body: Hello Jakeer,

I need the For Each section's details.. not the edit issue. lol

Also, the earlier log statement should be {{User in Organizations}} and not {{User in Organization}}.. please correct this..

Please share with me the screen shot of "For Each" and a newly run audit log so i can compare..


author: Jakeer
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

My bad I didn't share the correct screenshot.

![smart.png](https://community.atlassian.com/t5/image/serverpage/image-id/318629i4EF4934583F42874/image-size/large?v=v2&px=999 "smart.png")


author: Jakeer
body: ![new log.png](https://community.atlassian.com/t5/image/serverpage/image-id/318631i03D4D26C6062E3CD/image-size/large?v=v2&px=999 "new log.png")


author: Kalyan Sattaluri
body: Hello [@Jakeer](/t5/user/viewprofilepage/user-id/5437123)

I just tested and it worked for me. Only think I notice is that in your edit issue, you are again choosing a field in the "Choose fields to set" drop down... There should be no selection... We are using advanced section to edit the issue. Your edit issue screen should be like my below screenshot..

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/318639iACC173F327CAE215/image-size/large?v=v2&px=999 "image.png")


author: Jakeer
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

I made the changes and tested in the result i am getting-

![2.png](https://community.atlassian.com/t5/image/serverpage/image-id/318648i02839EE11514CFE4/image-size/large?v=v2&px=999 "2.png")![1.png](https://community.atlassian.com/t5/image/serverpage/image-id/318647iBBB6E1BBBCB61B5A/image-size/large?v=v2&px=999 "1.png")

Thanks,


author: Jakeer
body: Hi,

In the above screenshots you can see that the all common values in the teo groups are not getting copied.

![final.png](https://community.atlassian.com/t5/image/serverpage/image-id/318659i0205D557FB9595A2/image-size/large?v=v2&px=999 "final.png")

Thanks,


author: Kalyan Sattaluri
body: Hello [@Jakeer](/t5/user/viewprofilepage/user-id/5437123)

Hope you are doing well. Looks like we have run into a bug in Jira here.

Looks like when we are trying to "add" within a For /Each logic, its not completing all the steps.

I am also able to reproduce the issue but I dont have a solution yet.

Let me think some more and I will update you if I find a work around. Apologies for all the back and forth with no solution.


Tags: cloud

jira-service-management

jira-service-management-cloud