Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to use LookupIssue to update a custom field

Adam Hasselgren September 7, 2022

I created a new Jira issue type called "Customer".  The purpose is to store information about specific customer as well as identify who the project manager is for one.

On "Customer" I have a couple fields

  • Customer (drop down ,single choice)
  • Project Manager (user lookup, single choice)

 

On our normal stories, bugs, etc it also have the same fields.

Today I have some automation where if the "Customer" field is updated on a normal Jira ticket, it automatically updates the "Project Manager" field based upon the "Customer" field.  As of right now I have an automation script per project manager where I hard code customers (which works but not a good solution).

 

What I would like to do is have some automation where it can reference the new "Customer" artifact and lookup the project manager attached to a particular customer.  In Excel terms I'm basically looking to do a vlookup on a customer record to pull across the PM for a particular ticket.  I know I need to leverage the lookupissues function just can't get it to work.  Not sure if it's an issue because I have the "Customer" artifact in another project or if that shouldn't impact it.

Here is the field information

  • "customfield_10109": "PM"
  • "customfield_10063": "Customer"

Project Information 

  • Project A (all tickets)
  • Project B (test project where the customer artifact is located)

 

 

2 answers

1 accepted

0 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.
September 7, 2022

Hi @Adam Hasselgren ,

How far did you come so far? Could you show your current automation rule? That would help the community to better understand the problem.

Best
Stefan

Adam Hasselgren September 7, 2022

jira1.pngjira2.png

I'm sure I'm missing something but I did verify the customer had an entry in the ticket that matched on the "Customer" artifact.

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.
September 7, 2022

Hi @Adam Hasselgren ,

First thing: smart values are case sensitive. So try to change to {{lookupIssues...}} (capital „i“) in your esit action. 

furthermore (as the field is still a list) could you try the following in your edit action:

{{lookupIssues.PdM.value}}

see the documentation below:
https://support.atlassian.com/cloud-automation/docs/examples-of-using-smart-values-with-lists/

Please let me know if this works.

Best
Stefan

Adam Hasselgren September 8, 2022

Still no luck..I've included all the screenshots from each part of the automation just in case I'm completely missing something

jira3.png

jira4.pngjira5.pngjira9.pngjira6.pngjira8.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.
September 8, 2022

It seems your JQL doesn‘t even deliver any results.

I would suggest the following:

  • before your lookupIssue action add a „audit log“ action for debugging and let it just wright the value for customer field in your issue —> {{issue.Customer.value}}
  • it should not be necessary to store this value in a variable —> try to use the smart value from previous point in your JQL in the lookupIssues action (instead of the variable)

Best
Stefan

Adam Hasselgren September 9, 2022

Screen Shot 2022-09-09 at 9.23.36 AM.pngScreen Shot 2022-09-09 at 9.24.01 AM.png

 

So it looks like the PdM field is the thing giving me trouble.  I need to use {{issue.PdM.displayName}} for it to work correctly so getting there.  I now think I have an issue with my lookup...first issue I see is it doesn't want to display the customer from the lookup (log: Customer: {{lookupIssues.Customer}}

 

I did notice it can't "Validate query" as it's greyed out.  Is my syntax incorrect? 

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.
September 9, 2022

Hi @Adam Hasselgren ,

yeah as I mentioned before try to use the smart value directly in your lookupIssues.

so instead of your variable name (as shown in your last screenshot) use {{issue.Customer.value}}.

The JQL cant be validated as it uses a smart value which is resolved during runtime. This depends on the issue the rule is activated by.

You could just copy the jql and replace the smart value with a real example of one of your issues (like let‘s say you have Issue A and in the this issue the customer is John Smith —> try your jql in the normal issue search with „John Smith“ instead of you smart value)

Best
Stefan

Adam Hasselgren September 9, 2022

Screen Shot 2022-09-09 at 10.26.13 AM.pngScreen Shot 2022-09-09 at 10.26.41 AM.png

 

So the weird thing is in my JQL I'm only specifying the project "TA" but when I look at the log it's adding another project which is "AM".  Would this be my issue?  I have must customer record in TA but the tickets it's looking up against is in "AM".  Is there a way to modify this or do I need to move my "Customer" issue type into the "AM" project?

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.
September 9, 2022

It looks like your issues are located in different projets. is this correct?

In this case the rule must be configured as a multi-project or global rule. You can add another project to the scope in your rule details. All projects that are in the scope of your automation rule (so to say that are part of the processing) needs to be added.

Adam Hasselgren September 9, 2022

I updated it to global and now I feel like we're sooooo close..It's sees the correct values, the JQL is fixed, however when it tries to update the field it says I'm inactive.  It's the same custom field and I'm a valid user in both projects.

Screen Shot 2022-09-09 at 12.47.29 PM.png

Screen Shot 2022-09-09 at 2.40.45 PM.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.
September 10, 2022

Hi @Adam Hasselgren 

could you try to just use lookupIssues.PdM or lookupIssues.PdM.value in your edit action?

The displayName is mainly meant for user picker fields. As far as I got your description you are getting the information/value from a select field (single choice). So in this case the result is already the expected value (from a user picker field you would get the id and to use the plain name you would use displayName).

Best
Stefan

Adam Hasselgren September 12, 2022

Brilliant!  I just used the {{lookupIssues.PdM}} and it worked!!!!!  Thank you @Stefan Salzl for all your help!!!!! 

Like Stefan Salzl likes this
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.
September 12, 2022

AWESOME!!! sooo good to know you got that working.

It´s my pleasure ;)

0 votes
Pierre Allard
Contributor
June 9, 2023

Hello,

 

I'm trying to implement the same kind of logic but it seems I'm not able to retrieve

my custom field from my lookupIssue to put it in the audit log.

Here's the automation details:

1dzdzd.png

Here's the audit log:

3_automation.png

I've no error, the rule is a success...

I've tried with and without .value but it's never working.

Any idea ?

My custom field is a URL, could it be due to a known limitation with this kind of field ?

 

Thanks in advance for your help !

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events