Forums

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

linebreak with {{field.asJsonStringArray}}

J D June 28, 2025

I was able to make automation which goal is just create work items for each value in description separated by breakline. but for some reason i'm getting many more values in output, could you please help me with that issue?photo_2025-06-28_23-22-11.jpg

1 answer

1 accepted

4 votes
Answer accepted
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.
June 28, 2025

Hi @J D -- Welcome to the Atlassian Community!

What does the content / structure of your Description field look like?

And, why are you using the asJsonStringArray function?  That is normally used to build a JSON expression as text to perform a work item update.  That function does not produce a JSON expression which allows referencing attributes.

 

When you want to use data in a Description field delimited by newlines, please use {{issue.description.split("\n")}} to create the list source for the Advanced Branch.  And then use other text functions to further parse the results to check the content and create the work items.

And if you believe the parse content contains well-formed JSON, you could attempt to convert it (for referencing attributes) with the function jsonStringToObject:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#jsonStringToObject--

 

Kind regards,
Bill

J D June 28, 2025

@Bill Sheboy thanks for the response. 

that's what i got when used {{issue.description.split("\n")}}

Now, my description field is paragraph field that contains random words like:

Transmission

Ignition system

Engine

etc.

Could you please also provide me with details how to use jsonStringToObject? I feel like I'm doing it wrong way....

 

{{jsonStringToObject({{issue.description.split("\n")}})}}

I'm getting this error 
Failed to get value for jsonStringToObject({{issue.description.split("\n"): {{jsonStringToObject({{issue.description.split("\n")}})}}

 

 

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.
June 29, 2025

The example Description you show is plain text, and not a JSON expression.  Thus, there is no need to use any of the JSON functions.

To iterate over any non-blank lines in the Description, please try this:

  • advanced branch:
    • smart value: {{issue.description.split("\n").match("(.++)")}}
    • variable name: varLine
      • In the branch, use {{varLine}} to access each value

 

For future rule needs with jsonStringToObject() and other smart value functions, please see the example in the documentation: once inside a set of double-curly brackets, you do not need additional ones.  For example:

{{jsonStringToObject(issue.someField)}}

 

J D June 29, 2025

Thanks, that worked for me!!  

For some reason I was wrongly updating log action field! Thank you so much, @Bill Sheboy!

Last one is the answer. 

Like Bill Sheboy likes this
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.
June 29, 2025

UPDATE: thanks, and it looks like we were posting at the same time :^)

 

Please re-read what I posted above as it does not use the jsonStringToObject() function.  Instead it uses this expression in the advanced branch as the smart value to generate a list of the non-empty lines in the Description field:

{{issue.description.split("\n").match("(.++)")}}

 

Next, earlier you noted this:

Now, my description field is paragraph field that contains random words like:

Transmission

Ignition system

Engine

etc.

 

That is not a valid JSON expression.  And so jsonStringToObject() will not convert it.

 

Do you have an example of a Description containing a valid JSON expression which is not converting as expected?

 

 

Suggest an answer

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

Atlassian Community Events