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?
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:
Kind regards,
Bill
@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")}})}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
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)}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
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.