Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Apps & Integrations

Marketplace Partner Spotlight: Fine Software

Happy New Year, everybody! What better way to kick off 2022 than with a new Marketplace Partner Spotlight ✨ This month, we're getting to know Daniel Franz, co-founder of Fine Software. Fine Software ...

399 views 2 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you