Xporter not working with conditionals in iteration, even with Javascript

Adam Price October 26, 2020

Hello!

I have a custom Checkboxes field and I would like to create a report with all possible values listed alongside a checkbox indicating whether the value is included.

For example, assume the `ImpactCategory` custom field has the possible values ["Safety", "Cybersecurity", "Patient Satifaction"]. If my issue included just Safety and Cybersecurity, I would like to output:

Safety:
☒ Yes ☐ No
Cybersecurity:
☒ Yes ☐ No
Patient Satifaction:
☐ Yes ☒ No

I have tried several approaches here and nothing has worked so far.

When I use this format, the report includes a comma-separated list of the checked values in the field.

${ImpactCategory}

However, when I try to iterate through the custom field, it fails. For example, nothing is printed when I use this syntax:

#{for ImpactCategory}
${ImpactCategory[n]}
#{end}

I have been able to use Javascript with the following syntax to split the comma-separated string into an array and then iterate through the array. However, it only prints the last item:

%{ var output; var c = '${ImpactCategory[10183]}'.split(','); for (var i = 0; i < c.length; i++) { c[i] }}

When I attempt to use conditional logic in the Javascript, it prints nothing. For example:

%{ var output; var c = '${ImpactCategory[10183]}'.split(','); for (var i = 0; i < c.length; i++) { if (c[i]) === "Cybersecurity" { output = c[i] } else { output = "No" }} output; }

I noticed a similar question here: https://community.atlassian.com/t5/Jira-questions/Xporter-How-to-iterate-over-a-multi-element-custom-field/qaq-p/765742. However, even though the most recent comment says this is resolved, the solution does not work.

Is there any way to achieve this functionality?

Thanks in advance for your help!
-Adam

1 answer

0 votes
Sergio Freire - Xblend
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.
November 17, 2020

Hi @Adam Price 

Concerning the concrete situation you're facing, you'll need to provide more data so I recommend you reach out Xray support and the support team will be glad to help you out.

Best Regards,

Sergio 

_____________

Solution Architect and Testing Advocate @Xray

Personal blog on testing, Agile, and software development: https://sergiofreire.com

Follow me on Twitter: https://twitter.com/darktelecom

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events