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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,501,447
Community Members
 
Community Events
180
Community Groups

Set custom user field from assignee using smart values in Automation

Hello everyone!

I'm trying to set custom user field "Engineer" (user picker, used afterwards for several automation rules) from Assignee value on an issue transition. I've tried using several smart values options, this one seemed to be correct:
{
    "fields": {
        "engineer": [{
            "set": {{initiator.accountId.asJsonObject("id")}}
        }]
    }
}
(yes, i've tried setting "customfield_XXX" instead "engineer" and it doesn't help)

And this still doesn't work (it says SUCCESS in Audit log, but the field itself is empty. I've already tried adding re-fetch action after changing "Engineer" field - it still doesn't help.

I hope someone will be able to help me out

1 answer

1 accepted

1 vote
Answer accepted

Hi @Stanislav Sukhov 

 

What return {{initiator.accountId.asJsonObject("id")}}? Add Log action to your rule and put it there and see what it returns.

 

Regards,

Seba

Hi @Sebastian Krzewiński !
Thank you for your response! As expected, it returns json with user id:
{ "id": "615c4edd72f697006957659c" }

But I guess that what needs to be set to user picker is a full json with id, name, etc. I'll look through the documentation for json functions, try to use and right back later

Well, I haven't found a way to get full user json as it's represented in API. I can only access:

  • displayName
  • reporter.emailAddress
  • imeZone
  • accountId
  • avatarUrls

separately. And I don't get what should I put into user picker custom field via smart values :(

I've also tried to log what's inside this custom field and it's just an accountId, it's not a json. But setting id as a string doesn't help either.

So I don't know how to make it work

Hell yeah!
After about 50 tries, I've found the right option! Here it is:

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

This does work for me. I hope it'll help someone :)

Like Sebastian Krzewiński likes this

I'm happy that you resolve it :)

Like Stanislav Sukhov likes this
Sam Harding Atlassian Team Dec 05, 2021

Hi all,

Glad to see you found the solution. Just for a future note, a problem with the smart value used in the question, is that when using the set format of

{"set": <SOME_VALUE>} 

it must use the update clause (not the fields clause). So it would need to be

{
    "update": {
        "engineer": [{
            "set": {{initiator.accountId.asJsonObject("id")}}
        }]
    }
}

 When using the fields clause, you need to supply the direct mapping to the value, just like you have done in your answer. I hope that helps!

Cheers
Sam

 

@Sam Harding Hello

I've tried using update: field: set construction. But in that case Automation drops an error saying something like "Field 'Engineer' can't be both in 'fields' and 'update'". So I guess that this option doesn't work with custom fields

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events