hello all,
i'm doing lookup with 2 if statements and i want output in json that looks like this :
{{#lookupIssues}}
{{#if(equals(Billed.value, "Billed"))}}
{
"Issue_ID":"{{key}}",
"Task":"{{summary}}",
"Time":"0:0",
"TimeInvoiced":"{{#=}}{{worklog.timeSpentSeconds.sum.divide(3600)}}+{{subtasks.timetracking.timeSpentSeconds.sum.divide(3600)}}
{{/}}h",
"Solutionist": "{{assignee.displayName}}"
}{{^last}},{{/last}}
{{/}}
{{#if(equals(Billed.value, "Non-Billed"))}}
{
"Issue_ID":"{{key}}",
"Task":"{{summary}}",
"Time":"{{#=}}{{worklog.timeSpentSeconds.sum.divide(3600)}}+{{subtasks.timetracking.timeSpentSeconds.sum.divide(3600)}}
{{/}}h",
"TimeInvoiced":"0:0",
"Solutionist": "{{assignee.displayName}}"
}{{^last}},{{/last}}
{{/}}
{{/}}
],
i have problem that it's putting comma after every item, even after last one ...
{{^last}},{{/last}} should put comma only if the item is not last but it's not working :-/
can anyone help me on this ??
usually i have between 10-50 item in lookupissues...
Hi @Peter Skokan -- Welcome to the Atlassian Community!
The challenge with a expression like this one is your {{^last}}... handling is outside of the point when the expression can detect if there is a value or not for both conditions.
It appears the variable part of your planned JSON is swapping the Time and TimeInvoiced values between 0 and the worklog values. Is that correct?
If so, I recommend restructuring to have only those two fields inside of the filtering / conditional logic. Then the iterator can properly detect the last record when it reaches the Solutionist information at the end, and so only one {{^last}}... will be needed.
Kind regards,
Bill
Hello @Bill Sheboy
yes your recommendation working ! thank you, i did not realize i can use it like that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome; I am glad to learn that helped.
Please consider marking this question as "answered"; that will help others in the community with a similar need find solutions faster. Thanks!
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.