automation to edit a custom field using json (newbie alert)

Peter Degotardi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 24, 2024

I'm trying to get my head around json and failing miserably.

I have a custom field which is a drop-down list, that contains the values 0-36 & "> 3 years"

I want to run an automation comparing today's date with the date in another field and update the field with the calculated value.

customfield_12047 is the field holding the date to compare to.

customfield_12095 is the field I need to set 'Months open after agreed remediation date'.

It's easy enough with the gui to have the if "{{issue.customfield_12047.diff(now).months}} is greater than 36" then set the field value to ">3 years"

Less than 37 requires the JSON. This is as close as I've got but I'm obviously doing something fundamentally wrong.

{ "fields": { "customfield_12095": "customfield_12047.diff(now).months" } }

When run, the audit trail throws the error

Specify a valid 'id' or 'name' for Months open after agreed remediation date (customfield_12095))

Tips, tricks, pointers gratefully received (and yes, I think I have the logic right to cope with less than zero :) )

tks 

1 answer

0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 24, 2024

Hello @Peter Degotardi 

Welcome to the Atlassian community.

Reviewing this page

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

...for the details on setting a Single-select Custom Field, you should use code like this:

{
"fields": {
"customfield_12095" : {
"value": "{customfield_12097.diff(now).months}" }
}
}

 

Peter Degotardi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 24, 2024

Thanks! That's let me move on from the id error to :

Specify a valid value for Months open after agreed remediation date (customfield_12095)

 

Again, any pointers appreciated.

The if rule looks ok. The other rules for >1, >2, >3 years work (I'm still fiddling and have changed the numbers from when I first posed)

Jira1.png

The JSON seems right.

Jira2.png

The dropdown as defined

Jira3.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 24, 2024

Can you please provide screen images that show the entire rule and the details of the audit log for execution of the rule? 

I would also recommend that you use the Log action to print to the log the value of the smart value you're trying to use in the JSON.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events