Problems with #If block on Xporter

Jerry Gray May 27, 2021

Hi,  I'm having problems getting an if block to recognize true/false!!

I have the following expression evaluating to true/false successfully in a template:

%{ (‘${Labels}’.search(“it-plan”) >= 0) }

It will print true/false as appropriate.  BUT, when I put that expression in an If Block to control formatting I get nothing. But when I remove the if block my issues do get displayed

 

- Complete loop/block here:

&{for issues}

%{ (‘${Labels}’.search(“it-plan”) >= 0) }   <----This Works!

#{if (%{ (‘${Labels}’.search(“it-plan”) >= 0) }  )}  <--- This doesn't

${Key}

${Summary}

Team:

<Not implemented yet>

Assigned to:

${AssigneeUserDisplayName}

Department:

%{(‘${Department}’.length > 0) ? ‘${Department}’ : ‘No Department’}

State: 

${Status}

Target Completion:

<Not implemented yet>

Labels:

${Labels}

 

${Reporting Status}

 

#{end}

&{end}

 

 

1 answer

1 accepted

0 votes
Answer accepted
Jerry Gray June 1, 2021

I found a solution to my problem using another approach.  I switched to using a filter approach when I found I could use a "Contains" there.  So I updated the For loop and dropped the If block completely.  Works fine now.

 

&{for issues|filter=%{’${Labels}’.contains(‘it-plan’)}}

Kurt Willrich November 12, 2021

Have you had any luck (or need) using multiple Logical Operators (|| or &&) within the filter approach?  Mine seem to not work as they should.  

Rogério Paiva - Xray Xporter
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 19, 2021

Hi @Kurt Willrich 

It might depend on the usage of the operators; however, they should work as in Javascript since it uses a Javascript engine to process it.

If you need further help, please contact Xporter Support (http://Xportersupport.getXporter.app) to share your configuration for the support team to check.

Thank you.

Kind regards,
Rogerio Paiva [Xporter Support Team]

Kurt Willrich November 24, 2021

Thanks @Rogério Paiva - Xray Xporter I will reach out to the support team.

Kurt Willrich November 24, 2021

@Rogério Paiva - Xray Xporter I don't know what my SEN is and I'm not an administrator, just a Project Lead for my project.  Would you be able to take a look and see if you notice why I'm having problems?  The code snippet I use is this:

&{for issues|filter=%{'${Additional Details}'.contains('New Buy')&&'${Status}'.equals('Working')||'${Status}'.equals('Contract Development')||'${Status}'.equals('Awaiting Approval')||'${Status}'.equals('Backlog')||'${Status}'.equals('Barrier')||'${Status}'.equals('Waiting For Customer')||'${Status}'.equals('Active')||'${Status}'.equals('Contracting Department')}}

I would expect only issues that have "New Buy" listed in the Additional Details field would populate (which have any of the corresponding Statuses listed).  But what ends up happening is that some issues are populated that do not have "New Buy" listed in the Additional Details field.  Basically I'm only trying to pull those issues with "New Buy" listed with any of the Statuses present in the code.  

Thanks for the help!

Rogério Paiva - Xray Xporter
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 25, 2021

Hi @Kurt Willrich 

Yes, indeed, it is necessary to have the SEN (Support Entitlement Number) to have support. However, if you have an Active license (but don't know the SEN), open the ticket with a company email and provide information about the company, and we will try our best.

About your code, the OR conditions should be grouped between parenthesis to evaluate the OR conditions together. With the current condition, the AND only applies between the Additional Details and the Status "working"; it does not apply to all the other statuses.

I have expanded the code to give you an example of where the parenthesis needs to be placed:

javascript.png

In the template, you need to have this code in a single line.

Please get in touch with Xray Support (http://Xraysupport.getXray.app) if you need further help.

Thank you.

Kind regards,
Rogerio Paiva [Xray Support Team]

Kurt Willrich November 25, 2021

Thanks so much @Rogério Paiva - Xray Xporter !  I’ll give it a shot to see how it works. I figured I was missing something fairly simple but just wasn’t getting there. If I have any other issues I’ll get in touch with the support team as you suggested. Thanks again!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events