Forums

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

Trying to figure out how to set 'approvers' field (multiple users) but remove initiator of issue

Amed Moreno March 7, 2023

Hello Community,

I'm trying to configure automation to set a field called "Approvers" (multi-user picker) but then add a condition that IF one of the approvers is the initiator  --> remove their name/email as one of the approvers from the field.

One of my customers would like this as a safeguard so that if one of the approvers IS the ticket creator, they cannot self-approve their own request.

Screenshots of automation configuration below:

Note: in screenshots I changed the "create issue" trigger to "field value change" for ease of testing.

Everything seems to be ok until I get to the 2nd "Edit issue field (Advanced)".  I've tried several variations but get errors every time.

Any help truly appreciated.

Thank you very much and Kind Regards,

Amed

 

edit-fields-advanced.png

 

jira log.png 

 

1 answer

1 accepted

0 votes
Answer accepted
Mikael Sandberg
Community Champion
March 7, 2023

When you are adding/removing a user from a user picker field you have to use the Atlassian Id, and that is why you get the Token is empty error. The advanced edit should look something like this:

Screenshot 2023-03-07 at 1.29.47 PM.png

Amed Moreno March 8, 2023

@Mikael Sandberg 

Hi Mikael,

Thanks so much for the help and response but it did not work.  This time, no error, success but did not actually remove the initiator.  When I use accountId in condition, it does not pass the condition, I used emailAddress in condition so it passes and then your config in advanced but not expected result.

 

account-id-condition.png

 

edit-advanced-new-value.png

 

last-log.png

Mikael Sandberg
Community Champion
March 8, 2023

Is the approvers field a user picker field or a text field? Based on your log it makes me thing that you are using a text field, because if you are using a user picker field {{issue.approvers}} should give you the Atlassian Id instead of the email address.

Mikael Sandberg
Community Champion
March 8, 2023

Oh, wait, I just noticed that you are on server. So try this in the advanced edit:

{ "update": { "approvers": [ { "remove": "{{initiator}}" } ] } }

Amed Moreno March 8, 2023

@Mikael Sandberg 

Thanks again.  Yes, Data Center :).  This time got error below:

 

latest-advanced-field.pnglatest-log.png

Amed Moreno March 8, 2023

This is a multi-user picker field

Mikael Sandberg
Community Champion
March 8, 2023

Okay, try this:

{"update": {"approvers": [{"remove": {"name":"{{initiator}}"}}]}}

Amed Moreno March 9, 2023

@Mikael Sandberg 

It worked!!! :) 

However, I do have a strange behavior I was wondering you can help me figure out.  This has happened to me with automations before.  Not sure if it's a Server/Data Center quirk.

I have to run the automation twice.  The first run will fill the value of both approvers ( I can see this in the ticket) but the proceeding log in automation does not pick up the value and the condition to check "if initiator is in the approvers field" will return false (seen in screenshot 1).

When I run it again (with value of field populated with both users already), it runs successfully and removes the initiator but the last log at bottom of automation does not indicate the removal, still shows both users (seen in screenshot 2).

It's as if the automation is running too quickly to detect its own changes.  Have you every seen this behavior or is there an adjustment I can make to the automation rule to prevent this?

Thanks

Screenshots below:

 

working-on-2nd-log1.png

 

working-on-2nd-log2.png

Mikael Sandberg
Community Champion
March 9, 2023

This is expected, the automation only have access to the data in the issue at the time it was triggered. You can add the Re-fetch issue data after the edit of approvers and that should solve the issue.

Amed Moreno March 9, 2023

@Mikael Sandberg 

Thanks so much for all the help with this Mikael.  All working as expected now.

One last thing, if you don't mind sharing some wisdom.  How does one become so masterful in automation?  Just years of grinding and experience and over time, it comes?  Any recommendations on how to improve in this respect?  :) 

Mikael Sandberg
Community Champion
March 9, 2023

Haha, for me it has just been grinding and experience ever since we started using JSM 2+ years ago. Automations are now a big part of it and we keep coming up with new use cases all the time.

Suggest an answer

Log in or Sign up to answer