I am currently trying to leverage the "Custom data" approach for the "Web request body" for a given Automation trigger event and running into issues producing the "labels" array list of values with quotes ("") around each value:
Scenario #1: "labels" has a single value of "value1":
"labels": [
"{{issue.labels}}"
],
|--> produces for a single value: "value1"
"labels": [
"value1"
],
Scenario #2: "labels" has multiple values of "value1" and "value2":
"labels": [
"{{issue.labels}}"
],
|--> produces both values: "value1" and "value2"
"labels": [
"value1, value2"
],
|-> desired format where each value has quotes ("") around the values:
"labels": [
"value1",
"value2"
],
Attempted this syntax / format:
{{#issue}}"{{labels}}{{^last}}",{{/}}{{/}}
|-> produces this result:
"labels": [
"value1, value2",
],
Let me know if more details would help explain what I am attempting to achieve for multiple labels list.
Your expression has the quotation mark inside of the {{^last}} expression and it should be before that, like this:
{{#issue}}"{{labels}}"{{^last}},{{/}}{{/}}
And...you may not need this, as the asJsonStringArray can do all that for you, including the enclosing brackets:
Kind regards,
Bill
@Bill Sheboy EXCELLENT guidance!....I was able to get the multiple labels properly formatted using that "asJsonStringArray" approach link you shared:
|-> FINAL Custom data format that worked:
"labels": {{issue.labels.asJsonStringArray}},
|-> RESULTING desired formatted values:
"labels": [
"value1",
"value2"
],
FYI: the other suggestion above produced the same un-wanted format:
{{#issue}}"{{labels}}"{{^last}},{{/}}{{/}}
|-> Produced this formatted values:
"labels": [
"value1, value2",
],
Thanks again for the quick response and getting me un-stuck. Will mark this ticket as Resolved/Answered.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Arg...my bad as I answered too quickly: the labels are a list for this context and so that is where iteration is needed for your first version:
{{#issue.labels}}"{{.}}"{{^last}},{{/}}{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.