How do I print the for loop count value in Xporter template?

Geoff Wilson
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 9, 2016

Using the examples from XpandIT's Working With Advanced Templates documentation, how do I export just the total number of values resulting from this query and print that into a new line / cell?  It seems like it should be really straight forward, but I'm missing something

#{for i=JQLIssuesCount|clause=project = DEMO}
${JQLIssues[i].Key} - ${JQLIssues[i].Summary} 
#{end}

Ex: say in this code example, DEMO has 5 issues. so i = [0,1,2,3,4] I assume as an array of values totaling how many were found in the query.  How do I print the total count of values in that array so that my exported cell has a value of "5"?

 

The following do not work:

#{[i]} shows #{[0]} or #{[1]} or .... as iterates
#{JQLIssuesCount[i]}
#{i}

 

2 answers

1 accepted

2 votes
Answer accepted
Rui Rodrigues
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 12, 2016

Hi Geoff Wilson,

You just need to use the var: JQLIssuesCount to get the value. In this case: ${JQLIssuesCount}

Thank you.

 

Cheers,

RMRodrigues.

Geoff Wilson
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 2, 2016

I honestly do not remember what I was trying to do with this question, but this answer would likely make sense as JQLIssuesCount I guess is aware of what query took place and you can then put ${JQLIssuesCount} anywhere if so ... or only within that iteration? I have no idea haha. Only found this old question of mine by once again trying to tinker with Xporter and having tons of problems.

0 votes
Jörg Schäfer March 3, 2017

I have a similar question.

I want to print out the actual counter to produce numered headings "User Story 1...2...3" in my document.

I ve tried something (JQLIssues[stories], stories, stories.toString()...) but can't figure it out.

...
#{for stories=JQLIssuesCount|clause=issue in
linkedIssuesByDepth('${JQLIssues[epics].Key}', 1, 'fordert an') and issuetype = Story and ... }

User Story ${stories}

${wiki:JQLIssues[stories].anyContent}
#{end}

 

Can give me a hint, please?

Thanks in advance

Jörg

Rui Rodrigues
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.
March 3, 2017

Hi Jorg,

Here is an example:

#{for stories=JQLIssuesCount|clause=project = DEMO}
   ${JQLIssues[stories].Key}
   (Issue ${stories} of ${JQLIssuesCount})
#{end}

Cheers,

Rui.

Jörg Schäfer March 3, 2017

thx Rui,

so ${stories} was always right. With your examle in my template it looks like ... (Issue  of 10).

I am using XPorter Version 4.3.10-j6, since last week wink

Jörg

Rui Rodrigues
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.
March 3, 2017

Hi,

The example above is for Xporter 5.

For version 4, it's a little bit more tricky, but it works

#{for stories=JQLIssuesCount|clause=project = DEMO}
   ${JQLIssues[stories].Key}  
   (Issue %{stories =+'[stories]'.replace(/\D/g,'')+1;stories.toString()}
of ${JQLIssuesCount})
#{end}

Try it. It must work like a charm. wink

Cheers,

Rui.

Rui Rodrigues
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.
March 6, 2017

Hi,

Did it work?

Cheers,

Rui.

Jörg Schäfer March 6, 2017

Hi Rui,

Yesss! It works.

Thanks a lot, again.

Jörg

Rui Rodrigues
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.
March 7, 2017

Great.

Cheers.

Rui Rodrigues.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events