moirK
moirK

Reputation: 681

Print multiple instances of same variable in BI Publisher

I was actually trying to print multiple values of the same attribute Title with comma after each but couldn't remove comma after the last value which resulted in me writing complex loops.

Here I have initiated a count variable storeCount which increments and until it reaches the number of rows returned, I print Title and a comma that follows. Here's my code. I am getting syntax error. I would appreciate help fixing the code.

<?for-each@inlines:G_1?>
    <?xdoxslt:set_variable($_XDOCTX, 'storeCounter', xdoxslt:get_variable($_XDOCTX, 'storeCounter') + 1)?>
    Title
    <?if@inlines:<?count(G_1)?> != <?xdoxslt:get_variable($_XDOCTX, 'storeCounter')?>?>
        ,
    <?end-if?>
<?end for-each?>

Upvotes: 0

Views: 1165

Answers (2)

Ranjith R
Ranjith R

Reputation: 1589

This should work:

<?for-each@inlines:G_1?>
    <?xdoxslt:set_variable($_XDOCTX, 'storeCounter', xdoxslt:get_variable($_XDOCTX, 'storeCounter') + 1)?>
    Title
    <?if@inlines:count(G_1) != xdoxslt:get_variable($_XDOCTX, 'storeCounter')?>
        ,
    <?end-if?>
<?end for-each?>

Upvotes: 1

EdHayes3
EdHayes3

Reputation: 1953

  1. You should set the variable to 1 or something before the loop; Right now, you're essentially getting a non-existent variable and adding 1 to it on the first record.
  2. You cant have within an existing

Upvotes: 0

Related Questions