Forums

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

Automation: how to set an assignee through the JSON

Fiorella Santopietro
Contributor
March 21, 2022

Hi all,

I would like to create this automation rule:

when an issue is created in Service Desk, clone it, move in another project, and assign it to a specific user.

I can't find the right way to set it, through the JSON part:

{
"update": {
"fields": {
"assignee": {
"name": "Fiorella"
},
"labels": [
{
"add": "cloned"
}
],
"issuelinks": [
{
"add": {
"type": {
"name": "Cloners"
},
"outwardIssue": {
"key": "{{issue.key}}"
}
}
}
]
}
}

 I tried even with the id of the user, but it doesn't work.

Do you have any suggestions?

 

Thanks,

Fiorella

1 answer

1 accepted

3 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.
March 21, 2022

Hi @Fiorella Santopietro 

You cannot do that with the user's name, and instead need to find their account id, as shown in this example:

https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Using-smart-values

If this is always for the same specific user you may find their account id with a JQL search and then use that value.

Kind regards,
Bill

Fiorella Santopietro
Contributor
March 21, 2022

Thanks a lot for your reply.

Yes, 

I tried it, but it still doesn't work:

image.png

here is the code:

{
"update": {
"assignee": { "id": "{{initiator.accountId}}" },
"labels": [
{
"add": "cloned"
}
],
"issuelinks": [
{
"add": {
"type": {
"name": "Cloners"
},
"outwardIssue": {
"key": "{{issue.key}}"
}
}
}
]
},
"set": {
"fields": {"assignee": { "id": "{{initiator.accountId}}" }
}


}

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.
March 21, 2022

In that expression, you appear to be trying to changing assignee twice: once in the "update" and once in the "fields".

And, you have a "set" prior to "fields", but "fields" is a shortcut to using "update" and "set": https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#What--x27-s-the-difference-between-update-and-fields

Please try setting the field once, such as with this:

{
"update": {
"labels": [
{
"add": "cloned"
}
],
"issuelinks": [
{
"add": {
"type": {
"name": "Cloners"
},
"outwardIssue": {
"key": "{{issue.key}}"
}
}
}
]
},
"fields": {
"assignee": { "id": "{{initiator.accountId}}" }
}
}
Like # people like this
Fiorella Santopietro
Contributor
March 22, 2022

Thanks a lot!

It works!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer