Forums

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

Can I populate a user type custom field with the current user value via automationRule?

Soham Das September 20, 2021

I want an automation rule that uses 'Manual Trigger' and on clicking on that trigger a single user type custom field will get populated with the current username(User who trigered the event). I am currently using an automation rule where as Action I have used smart value with the following JSON:

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

 

But this is throwing error and even if it runs successfully the field is not updated. Can anyone please guide me towards the correct JSOn format to achieve this? 

FYI: Using Jira Datacenter instance

1 answer

0 votes
John Funk
Community Champion
September 20, 2021

Hi Soham,

What happens if you remove the asJasonObject part?

Soham Das September 21, 2021

Hi John,

In the audit logs I see it as a success but the custom field is not populating with any value. I removed the "asJsonObject" part. Used this instead:

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

John Funk
Community Champion
September 21, 2021

Maybe try this:

{
"fields": {
"customfield_14901": { "id": {{initiator.accountId.asJsonString}} }
},
}

If that doesn't work, try changing out your customfield value with assignee and see if that works. If so, then there is an issue with your custom field. 

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 29, 2021

Hi @Soham Das

I believe your syntax was initially correct however, you're in data centre. So I'm not sure what the field name should be. 

If you have a look at:

YOUR_SERVER_ADDRESS/rest/api/2/myself

You should see all the fields of a user, then follow that structure. It might username in server? Its been awhile since we forked and I'm hazy on server these days.

Suggest an answer

Log in or Sign up to answer