Forums

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

Creating a label in Project Automation Additional Fields with Custom Fields

Marc Isikoff
Contributor
July 18, 2023 edited

I need to create a label on the fly (e.g., during issue creation) in Jira Service Management.

I have the automation on issue creation setup and for labels I need to make it a combination of Text and 2 custom fields

Something like:

{
"update": {
"labels": [
{
"add": "Thank you and your details are " {{issue.fields.CustomField_13204.value}} "-" {{issue.fields.CustomField_13201.value}}
}
]
}
}

So I would like the label added to be "Thank you and your details are - Gemini - June".

The error I get in automation is: Error while parsing additional fields. Not valid JSON

Note: every example I have seen on this is either setting a label with just text, or setting a custom field's value, but never setting labels from text and custom field values.

2 answers

1 accepted

0 votes
Answer accepted
Marc Isikoff
Contributor
July 19, 2023 edited

OK here is the answer: if the customfield_13204 and 13201 are just text fields, there is no .value to use, nor any asJsonString.

 

{

"add" : "Confirmed-{{issue.Customfield_13204}}-{{issue.CustomField_13201}}"

}

Got: Confirmed-Gemini-June

 

Thanks all for getting me to the one yard line!

1 vote
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 18, 2023

you cannot have spaces in a label and it seems odd to have "Thank you and your details are" as part of a label. Why not simple "Gemini-June"?

Marc Isikoff
Contributor
July 18, 2023

Jack,

Thanks for pointing out the spaces, but yes, we can get: "Confirmed-Gemini-June"

But I keep trying to get my text custom field values as JSON and without any good examples, I keep getting Not valid JSON.

Latest snippet:

"labels": [
{
"add": "Confirmed-" {{issue.CustomField_13204.value.asJsonString}} "-" {{issue.CustomField_13201.value.asJsonString}}
}
]

To be sure, cf 13204 has text value of "Gemini" and cf 13201 has text value of "June"

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.
July 18, 2023

Hi @Marc Isikoff 

Adding to Jack's suggestions...

The problem appears to be the use of quotation marks in your JSON expression.  You should be able to just wrap the value once and include the smart values inside, perhaps like this:

"add": "Confirmed-{{issue.CustomField_13204.value}}-{{issue.CustomField_13201.value}}"

Kind regards,
Bill

Like • Jack Brickey likes this
Marc Isikoff
Contributor
July 19, 2023

Bill,

Thanks and though now it does not error, it's getting blanks for those to cfs.

I get "Confirmed--" as a label but my issue shows the values of 13204 and 13201 and those indeed have "Gemini" and "June".

I tried them using: {{issue.CustomField_13204.asJSONString}} and I get the label of:

Confirmed-"Gemini"-"June"

I'm guessing the asJSONString is putting the quotes around those values so we are close, but I want Confirmed-Gemini-June.

Suggest an answer

Log in or Sign up to answer