JSON for automation

Shaun Speers March 14, 2024

I've been racking my brain trying to get the right JSON format for an automation that runs every day. 

The audit log says - 

Error while parsing additional fields. Not valid JSON.

 

My JSON currently says - 

{
],
{ "Custom Field Name": {100_93": {"value":"100_10231", "child": { "value" : "10272"}
}
}
}

 

Can someone help me in telling me what is wrong? I can supply the names of my custom fields if that's helpful. 

Thanks.

4 answers

1 vote
Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 14, 2024

Hi @Shaun Speers and welcome to the community!

Assuming your field name is "100_93", it should work with this:

{ 
"fields": {
"100_93" : { "value": "100_10231", "child": { "value" : "10272"} }
}
}

 

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 14, 2024

So with this information you could either use the custom field id or the field name.  Depending upon how you want to go about this, your json would look like this:

Field Name

{ 
"fields": {
"Maintenance Category" : { "value": "10231", "child": { "value" : "10272"} }
}
}

Field ID

{ 
"fields": {
"customField_10093" : { "value": "10231", "child": { "value" : "10272"} }
}
}
Shaun Speers March 14, 2024

The rule will update successfully, but not run. The audit log just says "error creating the issue." 

JIRA1.PNGJIRA2.PNG

 

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 14, 2024

Hmm... I tried it in my test environment and it worked correctly.  Can you please share a screenshot of the audit log messaging?

Shaun Speers March 14, 2024

JIRA5.PNG

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 14, 2024

Given your last post re values... You do need to ensure the values exactly match.  Based upon the screenshot you sent to @marc -Collabello--Phase Locked-  you probably need to change it to this:

{ 
"fields": {
"customField_10093" : { "value": "Daktronics Sign(10231)", "child": { "value" : "Visitors(10272)"} }
}
}
Like Shaun Speers likes this
Shaun Speers March 14, 2024

I think we have the JSON! 

The automation will not run, and the audit log is a bit vague. The only thing i changed was the JSON. 

 

 

 

Shaun Speers March 14, 2024

JIRA6.PNG

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 14, 2024

Yeah the log is definitely lacking in detail.  Here are a couple things that I would look into:

  1. Verify that all required fields are included in your Create Issue action
  2. Verify the automation rule actor has permission to create issues. Doubt this one because it will usually give you that detail but still worth validating.
Shaun Speers March 14, 2024

The rule actor was Automation for JIRA. I went ahead and changed it to myself. Still producing the same error - a vague one. 

All starred fields are correct 

Shaun Speers March 14, 2024

I tried duplicating the automation in my sample space. I associated the fields with that project. But not the request types. In our sample space, I changed it to just a task. It's still erroring out with the vague error. 

0 votes
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 14, 2024

Hi @Shaun Speers 

Did you add that custom field to the site or is it from a marketplace addon / app?

 

Regarding the values you are trying to use in the JSON, have you confirmed they match exactly, including any spaces, to the allowed values?

One way to check that would be to create an issue with those exact values for the cascading field, and then use this how-to article to view what valid values would look like as JSON: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

 

Kind regards,
Bill

Shaun Speers March 14, 2024

The custom field was added from the site. 

If I go to try and find the smart value, I can only find the custom field ID (10093 in my case) 

Do I need to expand to see the parent/child values or should they be there already? 

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 14, 2024

If you use that how-to method, for an example issue with the parent / child values set for a cascade field, both should be visible in the JSON.

Shaun Speers March 15, 2024

If I plug in cascade list.value, under 10093, it does not show the correct parent and child values. Even though the issue I'm looking at has the correct parent/child values. 

 

I've redacted our URL to JIRA but copied the rest below. 

"customfield_10093": {
"self": "[redacted]/rest/api/2/customFieldOption/10241",
"value": "Mattresses",
"id": "10241",
"child": {
"self": "[redacted]rest/api/2/customFieldOption/10511",
"value": "STAINED MATTRESS/ REPLACE",
"id": "10511"

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 16, 2024

That would seem to indicate you are looking at a different field; however, which values are you looking for in that result: the id or the value?

When you edit a option / cascading field, you may set the selections by the id or the value.  The id is the internal Jira value for the field and is not user-controlled.

In some of your examples, you seem to be setting "value" to the id, not the human-readable dropdown text, and that will not work.

Please look at this example again to confirm how this is done:

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

0 votes
marc -Collabello--Phase Locked-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 14, 2024

I believe the JSON in your original post has at least 2 syntax errors.

  • line 2 has a single unmatched "]"
  • the field `100_93"` only contains a single quote, and so would lead to a parse error
Shaun Speers March 14, 2024

I'm starting to think this may have something to do with the names. This is what my old issues look like with the correct parent and child values. JIRA3.PNGJIRA4.PNG

Here are the names of the fields and my current JSON. 

I really appreciate the input. I'm getting the hand of JIRA but I'm definitely not a programmer. LOL! 

 

 

 

0 votes
Shaun Speers March 14, 2024

My field name is actually Interior Maintenace Category. The ID is 10093. 

My parent value ID is 10231 and the child ID is 10272.

 

It would not work with fields, so I changed it to update field. Still getting the same error. I want to be able to set the same parent and child value to this custom field every day. 

Currently looking like - 

{
"update field": {
"100_93" : { "value": "10231", "child": { "value" : "10272"} }
}
}

Suggest an answer

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

Atlassian Community Events