Forums

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

Automation for Jira - linking based on similar text field comparison

Masa Janezic November 10, 2021

Hi,

I want to create a global Automation rule which will link issues between different projects. 

When a new Access Request in System project is created, I want it to be linked to an HR project to a user's task. For this purpose I want to compare two custom fields:

  • Users' Full Name, Email, Username (Multi-line Text field) in System project
  • User's Full Name (Single-line Text Field) in HR project

As you can see, the information in HR project is more granular while on the System project we have three types of information clustered in a single field. I was thinking I could compare the fields with

"Users' Full Name, Email, Username" ~ "User's Full Name" 

or similar 

"Users' Full Name, Email, Username" starts with "User's Full Name"

So far everything has failed. I came across this thread and it didn't help. My automation rule looked like this at first:

1.png

Which returned this error

2.png

I changed the JQL and used custom field IDs instead:

project = HR and "customfield_11870" ~ "{{issue.customfield_11567}}"

A new error appeared:

3.png

I changed the JQL again to a combination of a custom field ID and a custom filed name:

project = HR and "User's Full Name" ~ "{{issue.customfield_11567}}"

But...

4.png

I'm not sure if this comparison between the two fields can even be done since the field values are essentially different. I was hoping the two could be compared as strings and a value of User's Full Name could be recognized in the field Users' Full Name, Email, Username. 

 

Thanks for the help,

Masa

1 answer

1 accepted

0 votes
Answer accepted
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.
November 10, 2021

Hi @Masa Janezic 

Have you tried writing to the audit log the issue field for the comparison?  I am wondering if there is some reserved character which is preventing the CONTAINS "~" from succeeding?

If you manually try an advanced filter search with a value and your JQL, does your query work as expected?

Kind regards,
Bill

Masa Janezic November 11, 2021

Hey @Bill Sheboy 

Thanks for your message and first of all sorry for a little late reply, I was away on a sick leave yesterday.

I can confirm that I get results in advanced search as follows:

  1. for the field "Users' Full Name, Email, Username"1.png
  2. for the field "User's Full Name"

2.png

Is this what you meant? 

 

Hope you're well,
Masa

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.
November 12, 2021

Thanks, Masa!

Did you try to add some writes to the audit log with the custom value field?  That will confirm if you are comparing to what you demonstrated with the stand-alone, advanced filter search test.

Masa Janezic November 15, 2021

Hi, @Bill Sheboy 

Thanks, it didn't occur to me to check the audit log for this. I entered the following JQL:

  • "User's Full Name" ~ "Leto Atreides"
  • "Users' Full Name, Email, Username" ~ "Leto Atreides"

Both returned the same 6 results:

1.png

Does this confirm what we're comparing? I'm not sure how to proceed. 

Thanks for your time and help.

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.
November 15, 2021

Hi, Masa.

Sorry I wasn't more clear.  What I meant was before you use the custom field value in the JQL in the rule, add a Log action to write the value to the audit log.  That will confirm what you are testing with JQL is what you expect when you run the rule.

After the rule runs, go to the Audit Log, expand the details, and then see if it matches what you expect.

Thanks,
Bill

Masa Janezic November 16, 2021

Okay, I think I get it now. Thanks Bill.

I added the action to the rule. You can see it in bold here:

1.png

After the rule was run, this is what I found in the audit log of the rule:

2.png

Branch rule in JQL somehow fails to find an issue in HR project which would hold a piece of information written in what I called user data above. 

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.
November 16, 2021

Looking at your rule image, is there a space after the quotation mark and before the custom field's smart value, or is that just the way it displayed?  An extra space could be part of the problem.

Masa Janezic November 16, 2021

There is no space, it's just the way it's displayed. 

1.png

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.
November 17, 2021

Ah, I think this query is mismatched:

  • Your HR project field only contains the name, correct?
  • Your System project field contains name, email address, and user name, correct?
  • But you are trying to match the second one to the first one in JQL.  That cannot work.

Instead you will need to extract the Full Name to perform the query.  For example:

project = HR AND "User's Full Name" ~ "{{issue.customfield_11567.split(',').first}}"

That should split apart the System field to get the name for the comparison.  A better solution is to not store multiple values in one field as this leads to risks of entry errors and parsing errors in the rule.

Like Masa Janezic likes this
Masa Janezic November 18, 2021

Hey @Bill Sheboy 

this solves it now. Thank you so much! That's exactly what I was looking for.

I am aware that this is far from ideal. We didn't think to link these issues when we were first configuring them. It would be best to granulate the field from our Access Request the same way it is done in the HR task. But at this point we have nearly 4000 Access Requests that would need some sort of difficult editing maneuver to pull this off. I'm afraid this chore will have to wait for a larger time window.

Here's the audit log from the rule after I've changed

1.png

Thanks again, hope you have a great rest of the week,
Masa

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.
November 18, 2021

Awesome!  I am glad to learn that worked for you.  Have a great day!

__Bill

Like Masa Janezic likes this

Suggest an answer

Log in or Sign up to answer