Forums

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

How to do automation to compare child and parent custom field being string?

lukasz.lichota November 18, 2021

I'm not sure where to start for this automation attempt: 

I have custom field (single select, string) indicating a delivery cycle for the work item (e.g. 2021-Q4-1). This field is set both at Story and Epic level and I'd like to write a rule that checks consistency, that is that the Story level value is no later than what is in Epic. The format of those strings is such that alphanumerical comparision (grater, equal, smaller) would be the right one for me. Is this possible to write such a rule? 

1 answer

1 accepted

1 vote
Answer accepted
Alex Koxaras _Relational_
Community Champion
November 18, 2021

Hi @lukasz.lichota 

Interesting question you've got there!

I would approach your problem with a slightly different angle, and instead of comparing the values on the right I would compare the option ids of your single select field. That is if you have the ability to set it up like below:

id value
 2021-Q1
 2021-Q2
 3 2021-Q3
4 2021-Q4
5 2022-Q1
6,7,8,9...... etc

What I would do is to actual compare the id of the selected value, instead parsing the text inside your value. So e.g. if I had set up a rule either in automation or within a workflow (with the use of an app) I would check the relation between the two selected values of the field in both story and epic. If the id of the value in story is greater than that of the Epic then:

  • either don't let the user create the story (validator inside a workflow)
  • or change the value of the story to at least match the value of the epic (jira automation, and upon issue creation)

 Would something like the above work for you?

lukasz.lichota November 18, 2021

@Alex Koxaras _Relational_ In terms of ids (I assume "id" is what is called "position" in the custom field value definitions) then yes, I can control that and it's already in right order, so if the ids are somehow accessible then comparing them is an option. 

I don't know much about automation (only created couple of simple rules) so could you please advice how would I approach this task? 

What I want is a scheduled job (schedule trigger) that will send an email or slack message with those issues that doesn't match. I thought I could use scheduled trigger with JQL query selecting a Stories I'm interested in. But then I'm not sure how to reach to parent and do the comparison. 

Alex Koxaras _Relational_
Community Champion
November 18, 2021

You could either use REST API to retrieve this single select ID, or use a 3rd party app, like JMWE or scriptrunner to do the comparison on the create screen of your story workflow, or use smart values within a Jira Automation. The latter could be easier.

For example you could do the following with Jira automation:

myAwesomeRule.png

 

And then on the audit log you would have these results:awesomeRuleResults.png

 

Thus having two integers value to compare!

Happy ending, no? :)

lukasz.lichota November 18, 2021

@Alex Koxaras _Relational_ thanks a lot! I'm in the middle of testing it and I noticed that the ids are not the positions (in the custom field administration) but they are very high numbers (e.g. 12131) which looks more like global counter? Fortunately they seem to be in the right order, likely becuase of the creation time/order (if they are global order indeed) but once created they cannot be influenced I guess, is that correct understanding? 

Alex Koxaras _Relational_
Community Champion
November 18, 2021

Yes they will not change, unless you delete a value and create another

lukasz.lichota November 19, 2021

@Alex Koxaras _Relational_ thank you very much for help, I think I managed to make this working (thankfully the ids are in right order). Out of curiosity and without needing to show this exactly, would the string comparison be doable in jira automation or one would need more external approach using e.g. API? 

Alex Koxaras _Relational_
Community Champion
November 19, 2021

Yes it's doable with smart values. If you go to the link I provided a few comments above. you'll find on your right a selection that has to do with string manipulation etc. Read it, since it has some interesting functions!

Kindly mark my answer as accepted, in order to help others in the community to find proper answers.

Thanx and be well!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events