JIRA Automation Add Current User to Custom Field

Jono Higgs September 10, 2020

I am wanting to automatically have the current user added to a Multi User Custom Field (called 'Developer') when a story changes status.

I have setup JIRA automation (using JIRA Cloud) and have got the 'Current User' to be set as the assignee (that is working),  but have been having issues with trying to get the current user added to the custom field.

I have setup the following Automation rule:

image.png

Where under the 'Edit Issue fields': I have tried the following:

1.

{
"fields": {
"Developer": {{initiator.accountId.asJsonObject("id")}}
}
}

Which gave the error:  Additional fields contains invalid field(s) in 'update' or 'fields' section.

 

2.

{ 
"update": {
"Developer": [{
"add": {{initiator.accountId.asJsonObject("id")}}
}]
}
}

Which gave the error:  Additional fields contains invalid field(s) in 'update' or 'fields' section.

 

3.

{
"fields": {
"customfield_10045": {{initiator.accountId.asJsonObject("id")}}
}
}

and

{ 
"update": {
"customfield_10045": [{
"add": {{initiator.accountId.asJsonObject("id")}}
}]
}
}

Both of which don't give any errors.  But seem to only set the field like 5% of the time.   I haven't been able to work out why the custom field is sometimes updated and sometimes it isn't. 

2 answers

1 accepted

4 votes
Answer accepted
Jono Higgs September 13, 2020

Thanks for your reply.  Have found that this is now working reliably:

 

{ 
"update": {
"customfield_XXXXX": [{
"add": {{initiator.accountId.asJsonObject("id")}}
}]
}
}

 

Not sure why it didn't seem to work last week, but have tested about 20 times today, and its worked every time.   

Brian Stults October 7, 2020

Is this still working for you? I'm trying to do the exact same thing. The automation reports success in the audit log, but the contents of the field don't change.

I've tried using the custom field ID as you listed it as well as the name — neither worked.

I've also tried the version that doesn't create the JSON object but it isn't working either, e.g.,

     "fieldname": { "id": "{{initiator.accountId}}" }

Any suggestions? 

Jono Higgs October 11, 2020

@Brian Stults 

Yup,  we're still using the following code:

{ 
"update": {
"customfield_10038": [{
"add": {{initiator.accountId.asJsonObject("id")}}
}]
}
}

And this is working perfectly for us, where customfield_10038 is a multi user picker custom field.

 

One thing I noticed that caught me out a little when I was originally implementing this, was that it sometimes takes a few minutes for the changes to come through.  E.g. I would see the assignee field get updated really quickly on the UI (by the automation), but the multi user picker seemed to take a little longer and I had to manually refresh the page / JIRA story to see the changes.    But the changes are coming through for us. 

Christopher Mohr May 5, 2021

You would have to use setadd is not supported.

 

{ 
"update": {
"customfield_10038": [{
"set": {{initiator.accountId.asJsonObject("id")}}
}]
}
}
Like zfinannee likes this
Mignonne Yap July 20, 2022

I have a similar use case and have used the solution from Jira's documentation - https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/

 

{ "fields": { "assignee": { "id": "{{initiator.accountId}}" } } }

 

However, my automation stopped working a day or so ago. I get the error: "Additional fields contains invalid field(s) in 'update' or 'fields' section." Some of the solutions here have helped in that the audit logs show it was a success but the actual issue does not reflect any changes. I've tried checking in after a few minutes to a few hours but still nothing.

Please help?

0 votes
Jira Guru
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.
September 11, 2020

Hi @Jono Higgs 

You can try setting up the developer field with the below smart value

{{initiator.displayName}}
Sergei Gridnevskii
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.
February 1, 2021

Not a good idea - Jira Cloud will turn off display names at some point due to GDPR. It is better to use ids.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events