Forums

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

Jira Automation: Updating # of issues in an Epic and totalling of Story Points

Jim Smith
Contributor
August 11, 2023

Scenario: Epic link changes on a story.  Automation goes out and looks up the original Epic and updates the number of issues assigned to the Epic and adjusts the number of Story Points in the Epic.

Problem: I have a duplicate automation that is supposed to do the same thing for the Target Epic...ie the one that the story moves to.  That automation is failing and I can't figure out why.  I've mirrored the Source automation, changing {{toStiring}} to {{fromString}}, but it fails for some reason.

Here is the JSON for the automation:

{"cloud":true,"rules":[{"id":13834518,"clientKey":"d88b9191-773c-3001-ac86-ac5e2a5ecd89","name":"4.Update SP and Nbr of Issues - Epic link changed - Target","state":"DISABLED","description":"","authorAccountId":"712020:977bff7a-a0c5-4ee1-ac25-7c01a7a56f5b","actor":{"type":"ACCOUNT_ID","value":"557058:f58131cb-b67d-43c7-b30d-6b58d40bd077"},"created":1690894366868,"updated":1691591066271,"trigger":{"id":"302225689","component":"TRIGGER","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.issue.event.trigger:updated","value":{"eventKey":"jira:issue_updated","issueEvent":"issue_updated"},"children":[],"conditions":[],"connectionId":null},"components":[{"id":"302225691","component":"CONDITION","parentId":null,"conditionParentId":null,"schemaVersion":3,"type":"jira.issue.condition","value":{"selectedField":{"type":"ID","value":"issuetype"},"selectedFieldType":"issuetype","comparison":"NOT_ONE_OF","compareValue":{"type":"ID","modifier":null,"value":"[\"10000\",\"10010\",\"10490\"]","multiValue":true,"source":null}},"children":[],"conditions":[],"connectionId":null},{"id":"302225693","component":"CONDITION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{#changelog.epic link}}{{toString}}{{/}}","second":"Empty","operator":"NOT_EQUALS"},"children":[],"conditions":[],"connectionId":null},{"id":"302225695","component":"BRANCH","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.issue.related","value":{"relatedType":"jql","jql":"issue = {{#changelog.epic link}}{{toString}}{{/}}","linkTypes":[],"onlyUpdatedIssues":false,"similarityLimit":40,"compareValue":0},"children":[{"id":"302225697","component":"ACTION","parentId":"302225695","conditionParentId":null,"schemaVersion":1,"type":"jira.lookup.issues","value":{"id":"_customsmartvalue_id_1689086516698","name":{"type":"FREE","value":"lookupIssues"},"type":"JQL","query":{"type":"SMART","value":"\"Epic Link\" = {{#changelog.epic link}}{{toString}}{{/}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"302225698","component":"ACTION","parentId":"302225695","conditionParentId":null,"schemaVersion":1,"type":"codebarrel.action.log","value":"New Epic Link value: {{#changelog.epic link}}{{toString}}{{/}}","children":[],"conditions":[],"connectionId":null},{"id":"302225699","component":"ACTION","parentId":"302225695","conditionParentId":null,"schemaVersion":1,"type":"codebarrel.action.log","value":"Original Epic Link value: {{#changelog.epic link}}{{fromString}}{{/}}","children":[],"conditions":[],"connectionId":null},{"id":"302225700","component":"ACTION","parentId":"302225695","conditionParentId":null,"schemaVersion":1,"type":"codebarrel.action.log","value":"Total SP after issue is removed from Epic: {{lookupIssues.story points.sum|0}}","children":[],"conditions":[],"connectionId":null},{"id":"302225701","component":"ACTION","parentId":"302225695","conditionParentId":null,"schemaVersion":1,"type":"codebarrel.action.log","value":"Nbr of issues after issue is removed from Epic: {{lookupIssues.size|0}}","children":[],"conditions":[],"connectionId":null},{"id":"302225702","component":"ACTION","parentId":"302225695","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"Total Number of Story Points"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:float","type":"SET","value":"{{lookupIssues.Story Points.sum|0}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null},{"id":"302225704","component":"ACTION","parentId":"302225695","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"Number of Issues per Epic"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:float","type":"SET","value":"{{lookupIssues.size}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null}],"conditions":[],"connectionId":null}],"canOtherRuleTrigger":false,"notifyOnError":"FIRSTERROR","projects":[],"labels":[],"tags":[{"id":39373668,"tagType":"IS_RULE_UPDATED","tagValue":"true"}],"ruleScope":{"resources":["ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10191","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10072","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10171","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10192","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10176","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10145","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10112","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10172","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10183","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10164","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10152","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10119","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10129","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10038","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10117","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10007","ari:cloud:jira:78db38a2-52b2-44cf-ac8f-1689cf94905f:project/10149"]},"ruleHome":{"ruleLifeCycleHome":{"locationARI":"ari:cloud:jira-software::site/78db38a2-52b2-44cf-ac8f-1689cf94905f"},"ruleBillingHome":{"locationARI":"ari:cloud:jira-software::site/78db38a2-52b2-44cf-ac8f-1689cf94905f"}},"writeAccessType":"UNRESTRICTED","collaborators":[],"billingType":"NORMAL"}]}

It fails with this error:

Issue condition
The following issues passed:
TFM-5280
Advanced compare condition
The following issues passed:
TFM-5280
Branch rule / related issues
Error searching for related issues. This is most likely because the following issues don't have a related issue of the type you specified. Try narrowing your search to only include issues that contain links to related issues:
TFM-5280: "((issue = ) AND (key != TFM-5280)) AND (project in (10192,10191,10172,10183,10072,10171,10152,10129,10117,10007,10119,10176,10164,10145,10112,10149,10038))" - Error in JQL Query: Expecting either a value, list or function but got ')'. You must surround ')' in quotation marks to use it as a value. (line 1, character 11)

1 answer

0 votes
Trudy Claspill
Community Champion
August 11, 2023

Hello @Jim Smith 

Can you possible provide screen images for the rule? Reviewing the images is much easier than deciphering the JSON.

From what I can decipher the Branch to related issues using JQL is failing, and it looks like your JQL is:

issue = {{#changelog.epic link}}{{toString}}{{/}}

Have you tried adding a Log action before the branch to print out the smart value

{{#changelog.epic link}}{{toString}}{{/}}

The error message indicates that smart value has no actual value:

"((issue = ) AND 

Jim Smith
Contributor
August 11, 2023

Screenshot 2023-08-11 at 11.44.48 AM.pngScreenshot 2023-08-11 at 11.45.05 AM.png

Trudy Claspill
Community Champion
August 11, 2023

Actually, you don't need to use the JQL option for the Related Issues branch. You want to look at the Epic to which the issue is currently assigned, so just use the Epic (parent) option.

Screen Shot 2023-08-11 at 10.56.26 AM.png

Jim Smith
Contributor
August 11, 2023

...Ok, I'll make that change and test! thank you!

Like Trudy Claspill likes this
Jim Smith
Contributor
August 14, 2023

@Trudy Claspill I made that change and the same error occurs, just in a different spot...

Screenshot 2023-08-14 at 5.58.21 AM.png

Trudy Claspill
Community Champion
August 14, 2023

Can you show us the changed rule?

If you have changed the For branch to use "Epic (parent)" then in the Lookup Issues action use "{{issue.key}}" instead of "{{#changelog... {{/}}"

Jim Smith
Contributor
August 14, 2023

Right, so It is changed to Epic (parent) with the change you're suggesting the lookup would change to {{issue.key}}{{toString}}{{/}} ?  This change would also then logically

need to be applied to the "Add value to the audit log" as well?

Screenshot 2023-08-14 at 11.03.09 AM.png

Trudy Claspill
Community Champion
August 14, 2023

You don't need this smart value at all anywhere:

{{#changelog.epic link}}{{toString}}{{/}}

This rule is running against that has already been confirmed to be linked to an Epic. You don't need to reference the changelog at all.

In the Lookup Issues action replace

{{#changelog.epic link}}{{toString}}{{/}}

with

{{issue.key}}

That should get you the key of the Epic parent, which is the context of the branch.

Jim Smith
Contributor
August 14, 2023

Ok, I'm probably not all the way there yet in understanding this as I'm totally out of my element here! I'm including two screen shots, the first with the top part of the automation along with the audit log in it's entirety.  The second screen shot is of the bottom part of the automation.  

I believe I need to take out the {{#changelog.epic link}}{{toString}}{{/}} for the "Compare two values" step and change it to {{issue.key}}?

Screenshot 2023-08-14 at 11.45.26 AM.pngScreenshot 2023-08-14 at 11.46.21 AM.png

Trudy Claspill
Community Champion
August 14, 2023

Hi @Jim Smith 

Sorry, I've been multi-tasking and not giving you complete answers. I'm focused now. :-)

In this step replace {{#changelog.epic link}}{{toString}}{{/}} with {{issue.epic link}}

If you tried to use {{issue.key}} here it would be looking at the key of the trigger issue, not the Epic Link field of the trigger issue.

Screen Shot 2023-08-14 at 10.56.53 AM.png

 

Here, replace {{#changelog.epic link}}{{toString}}{{/}} with {{issue.key}}

Screen Shot 2023-08-14 at 10.59.00 AM.png

 

 

Remove all Log actions that reference {{#changelog.epic link}}{{toString}}{{/}}

If you want to print the Epic key into the log then

- within the For branch use the smart value {{issue.key}} or {{triggerIssue.epic link}}

- outside of the For branch use the smart value {{issue.epic link}} or {{triggerIssue.epic link}}

 

{{issue}} refers to the issue that currently has focus.

When you initially trigger a rule, the issue that has focus is the issue that triggered the rule. To reference fields in that issue, as long as you are not within a branch you can use {{issue.fieldName}}. You can use {{triggerIssue.fieldName}} anywhere in a rule to reference the fields from the issue that triggered the rule.

When you start a For branch, you are changing the focus to the issue that the For branch is referencing. When you use "For: Epic (parent)" you are changing the focus to the parent Epic. While you are within that branch (the indented steps) {{issue}} will refer to the Epic rather than the trigger issue.

If your branch is looping over multiple issues (such as For: Sub-tasks) then each each of the indented steps will be executed for one sub-task at a time, and {{issue}} will refer to the sub-tasks currently being acted upon.

So, within a branch if you need to refer to the fields from the trigger issue you need to use {{triggerIssue}} rather than {{issue}}.

 

I hope that makes things more clear.

Like Bill Sheboy likes this
Jim Smith
Contributor
August 14, 2023

It does! well, kinda! after making those changes, the source Epic is being changed and the target epic is being updated to 0 on both # of issues and # of story points.  and, second the error is still occurring.  

I'll catch this thread up with screenshots in the morning.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events