Forums

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

How do I iterate through the result of a JQL search and update fields in a linked issue

Dave Stillwell
Contributor
June 19, 2025

Using JSM Automation, the following works as expected

Screenshot 2025-06-19 144501.png

But when I try to do a scheduled trigger using JQL to filter for issues using and issueFunction in hasLinks("Requires Quality Issue") in order to update the linked issue with Copy Product Model from Current Issue, my audit log indicates "Success" but the linked issue is not updated and I see No related issues could be found.  I have over 200 issues with linked issues that need to be updated so I am hoping I do not have to do each one manually.

1 answer

2 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2025

Hi @Dave Stillwell 

Have you confirmed that ScriptRunner JQL function works with automation rule, Scheduled triggers?

Are all of the issues in the same project or in multiple projects?  If in other projects, what is the scope in the details at the top of the rule?

Kind regards,
Bill

Dave Stillwell
Contributor
June 20, 2025

@Bill Sheboy 

The issues are in the same project. just different issue types.

I believe the ScriptRunner JQL function is working since the audit log indicates less JQL results than I got if I did not add the haslinks function.  The last testing I did was to change the JQL to reference a single issue using key=, so unlikely the scriptrunner portion is not the cause of the issue.

If my issue is A123 and my linked issue is B123 and I run the automation manually from A123, the rule runs as expected and B123 is updated.  If I run the automation as scheduled trigger and filter for key=A123 then the rule doesn't work.  I am wondering if I am using the correct Copy from process in the scheduled trigger flow.

I am not sure if might be the cause of the problem, but I am working with custom Insight Data Fields,

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 20, 2025

Thanks for that information, and...

When you note this:

If I run the automation as scheduled trigger and filter for key=A123 then the rule doesn't work. I am wondering if I am using the correct Copy from process in the scheduled trigger flow.

What do you mean "the rule doesn't work": the audit log shows an error, or no error and the field copy does not happen, or something else?

 

Would you please show images of the Scheduled Trigger and the Branch details?

Dave Stillwell
Contributor
June 20, 2025

Oops I just saw that in my test that issued the key for the quality issue, which is why I received the "No related issues could be found" since a quality issue would not be linked to a quality issue.

But I did find my fix.  I changed the "Copy From" to use Trigger Issue versus Current Issue.  My assumption was that Trigger Issue was for a Manual Trigger and that Current Issue was used when iterating through the results of the JQL query.

@Bill Sheboy 

Thanks for your patience.

Like Bill Sheboy likes this
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 21, 2025

Well done solving this!

FYI -- The {{triggerIssue}} smart value is always the trigger one (when there is one for the specific trigger used) and {{issue}} can vary based on context within the rule.

To learn more, please see this article where I describe this difference:

https://community.atlassian.com/forums/Automation-articles/Automation-concepts-Smart-Values-and-Scope-of-Information/ba-p/3024503

Suggest an answer

Log in or Sign up to answer