Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Copy value from field in one project to same field in another project based on another field value

Craig
Contributor
February 25, 2022

I'm looking to automate copying the value of a custom field Version In Project X, to the same Version field in Project Y.

The two issues in their respective projects are not linked. But I have a field Name in both projects which already contains the same value.

Where the value in Name matches between the issue record in X and I want to copy the value of Version from X into the Version field in Y.

It's possible that in Y multiple records with the same Name exist, I would like all of them to be updated.

Is this possible using automation & if so how?

 

 

2 answers

1 accepted

2 votes
Answer accepted
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 25, 2022

Hi @Craig ,

I tried to create a rule that fullfills your requirement (as far as I understood your need correctly ;) ). Please be aware that your rule need to be a multi project or global rule as it needs to operate across 2 or more projects. 

By using smart values the rule can check for issues in project X containing the same value as the (trigger-)issue in project Y. Important here is to think of the trigger (i just picked a manual trigger, that is something you have to figure out when your rule should be triggered to run).

Below is a screenshot of what I built.

Maybe for better understanding:

  • the trigger issue is in project X, has set field: Mandant = 330 and Country = USA
  • then the jql searches for issues in project Y with the same value for Mandant as triggerissue in project X (which is 330) --> solved with smart value in jql
  • the jql finds several issues in project X with Mandant = 330 (same as triggerissue) and edits the found issues, field "Country" to the same value than triggerissue in project X (which is USA)

image.png

Hope I got your requirement right and this helps.

Best
Stefan

Craig
Contributor
February 25, 2022

Thank you Stefan, it works like a dream!

Like Stefan Salzl likes this
kdickason
Contributor
May 31, 2022

@Stefan Salzl  I have two issues on two different projects (ProjectA and ProjectB) Linked.  I would like to copy the Summary field on ProjectA to CustomField on ProjectB for every linked issue.    I am trying to figure out where you set up what you did in the screen cap you provided.  I do not understand where you did this.  Can you walk me through how I can do what I'm trying to do and where to set it up?  Thank you in advance for any help!  

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 1, 2022

Hi @kdickason 

What you see in the screenshot is the Automation for jira (A4J) feature. If you are on jira cloud this is feature is available by default. If you are not familiar to it yet I would recommend to read through the basics and trying to build some examples:

https://www.atlassian.com/de/software/jira/guides/expand-jira/automation

 

Please let me know if you have any further questions.

Best
Stefan

kdickason
Contributor
June 1, 2022

So this is not possible without a (pricey) add-on like Automation.  Darn.  Thank you for explaining.

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 1, 2022

@kdickason 

right now A4J is only part of jira cloud. On DC/Server there is a paid add-on but this is planned to be added into Jira (same as in cloud) within the next month.

see following link:
https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-will-be-included-in-Jira-Data-Center/bc-p/2042669#M6578

Best
Stefan

kdickason
Contributor
June 1, 2022

Thank you for this!!  I'll watch for the release.  Unfortunately, there is a comment about this being delayed.  

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 1, 2022

Hi @kdickason 

In case Scriptrunner is installed in your Jira Instance --> that would feasible too to solve this use case.

Best
Stefan

kdickason
Contributor
June 1, 2022

Yes, we have scriptrunner!  I am not a strong scripter, though, and their built-in scripts did not handle what I need to do.  Ultimately here's what I need.  I have two tickets on two different projects (Project A and Project B) that are linked by an Linked Issue.  I need the Summary field from Project A to populate a custom field on Project B for any tickets that are linked together.  Is there any chance you could help me write this script or give me any direction??  There will only be 1 Link from Project B to Project A.  So there's no chance Project B's ticket will have multiple Project A links.

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 4, 2022

Hi @kdickason ,

unfortunately I‘m not very proficient with scripting either. I just started my journey and asked similar question. Nevertheless I got very good hints to start from in the following post:

https://community.atlassian.com/t5/Jira-questions/How-to-translate-from-A4J-to-Scriptrunner/qaq-p/1998239

Just did small steps with try‘n‘error.

Hope this also gives you some starting input.

Best
stefan

Ivor
Contributor
June 9, 2022

@Stefan Salzl I have the same troubles but I don't seem to get the same outcome as described. The scenario is quite similar:

1. The trigger issue is from project A. Let's name the trigger issue to be "ISS-A".

2. The source issue "IMP-B" is from project B (from screen its IMP). Redacted for confidentiality.

3. I want to copy the fields from the issue in project B to the issue in project A.

If I follow the same triggerissue smartvalues as described, what happens is that:

1. It will copy the values from the ISS-A to IMP-B. The results are the opposite of what I wanted. I wanted to copy the values from IMP-B to ISS-A.

I attached the example of my rule below. I think I am very close to achieving what I want, but just stuck for couple of hours - maybe i'm doing this more complicated than it already is.

copyissue.png

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 9, 2022

Hi @Ivor 

as your rule is using a branch it changes it´s context/scope of action to the issues that are found by the branch-condition:

  • the jql in your branch is selecting "ISSUE-B"
  • as the action is in your branch it is processed against ISSUE-B

I would suggest to

  • change the branch to a "lookup issue" action with your jql
  • adding the "edit issue" after your lookup issues
  • using smart values of {{lookupIssues}} instead of {{triggerIssue}} in your "edit issue" action

One more thing that comes to my mind:

The JQL seems a bit generic. Can you be sure that there is only 1 issue in project B with this email adress in the field?

Best
Stefan

Ivor
Contributor
June 9, 2022

hi @Stefan Salzl 

Thanks for the advice, I did the modifications based on your response and it now works. This is the final flow that works for me. Sharing the screenshot so that might benefit others. 

copyissue2.png

Tbh, what I was doing was a workaround on JSM to store referential data of user information by importing that into the IMP project (which is imported manually) due to limitations on integration with an external DB/app. Each record is confirmed to be a unique, so the jql query always returns only 1 record.

I guess if there are several records that are returned by the JQL, then we probably need to set the array value to [0] to only retrieve the first object? Though it doesn't impact my use case, it would be very informative to be able to do this on datasets that have more than 1 record returned.

Also kinda annoying that JIRA isn't able to validate smartvalue expressions, autocomplete or have a expression builder built directly into flow; MS with their power platform is already ahead of atlassian in this respect. 

0 votes
Hila Ben Halevi February 28, 2023

Hi @Stefan Salzl ,

I have the same issue like Ivor had, and I've tried your solution to use the lookup action, but unfortunately the Lookup Issues action does not exist for the Data Center versions of automation rules. 

Do you have another solution for DC?

Thanks,

Hila. 

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 28, 2023

Hi @Hila Ben Halevi - welcome to the community

the simpliest way that comes to my mind would be to call the jira api (search endpoint) with the „send web request“ action. see the link below:

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-get

You could then use the response of the api call with the smart value 

{{webResponse}} 

guess for the issue the whole smart value would be (not 100% sure, please double check)

{{webResponse.body.key}}

 

Best
Stefan

Suggest an answer

Log in or Sign up to answer