multiple copies and watermarks

jaxNZ

Member
Hi There,
I've got multiple copies of a SO Invoice thanks to eewon(Dave) and watermark thans to Tim Dexters nice little solution.
But I cant get the watermark value to change for each copy.
I need 3 copies of an invoice each with its own watermark.

In the Word Header I have the following:
<?variable:x;3?>
<?for-each@section:On_Payment_Terms_S3?>
<?variable@incontext:currentorder;.?>
<?for-each@section:xdoxslt:foreach_number($_XDOCTX,1,$x,1)?>

This does the looping.

I've added a word watermark; in the text I put <?$wMark?>.

In the body I adde a field and then added the following to this field.
<xsl:variable name="wMark" select="xdoxslt:ifelse(position()='1’,'Canceled','Approved')"/>

position() gives me the counter of the loop. Displaying this I can see it goes 1,2,3,1,2,3,1,2,3.

But the watermark is Canceled on all pages. I should seeCancelled,Approved,Approved, Cancelled,Approved,Approved etc.
When I change the value from 1 to 2, I get Approved on all pages.

Can anybody help? I think I need to make the wMark variable local to eacy copy interation. But not sure and not sure how to do it either.

Any ideas Welcome!
thanks
Jackie
 
I believe the issue here is the use of an xsl variable. Quoting from XSLT tutorials, 'once the value of an xsl variable is set it cannot be changed'. Making the variable 'local' to a template and then calling the 'template' to do your work might resolve the issue. However, I don't think that is a possibility here.

Try the following :

In the text of the word watermark , <?xdoxslt:get_variable($_XDOCTX,'wMark')?>


In the body, add a field and in the field add
<?xdoxslt:set_variable($_XDOCTX,'wMark',xdoxslt:ifelse(position()='1','Canceled','Approved'))?>

I think this should work.
 
Sorry, my bad. I posted an incorrect solution using the xdoxslt get & set variable - assuming this would get around the xsl variable problem. However, it does not. In fact you will end up with no watermark at all.

Should have tested first ! so ...
I tried several other methods, all with no success. It seems to me that the watermark 'code' is executed only once at the beginning of the BI process and is 'static'. I tried a number of things becasue we need similar functionality - however, I was never able to find any way to make the watermark change from page to page.

my apologies for the misdirection.
 
Hey there,
Thanks for trying to help!
So what happened last night;
Windows Update happened on my work laptop and BI didnt work anymore. Downloaded 11.1.1.5; had a few issues; deleted some EXD files; and am now working again.
Except the code that worked yesterday dont work no more!
the code in question was <xsl:variable name="wMark" select="xdoxslt:ifelse(position()='1’,'Canceled','Approved')"/>
inside my form field. it was the ifealse bit that didnt work.
So I tried the sub-template (following your suggestion) as follows:
<?call@inlines:WTM?><?with-param:pCurrentCopy;position()?><?end call?>

<?template:WTM?><?param:pCurrentCopy;0?>
<?choose:?>
<?when:pCurrentCopy=2?>
<?xdoxslt:set_variable($_XDOCTX, 'wMark', ‘TEST’)?>
<?end when?>
<?otherwise:?>
<?xdoxslt:set_variable($_XDOCTX, 'wMark', ‘POD’)?>
<?end otherwise?>
<?end choose?>

<?end template?>

And changed the text in the Watermark to <?xdoxslt:get_variable($_XDOCTX, 'wMark')?>

Result is I get a watermark but it is always 'POD'; the initial When test always fails. I've tested this against 0-3 and it always fails.

Any ideas?? Thanks J
 
Hey Roland,
I have the solution
smile.gif

Same as in my last post except the sub-template is now
<?template:WTM?><?param:pCurrentCopy;0?>
<?choose:?>
<?when:$pCurrentCopy=1?>
<?xdoxslt:set_variable($_XDOCTX, ‘wMark’, ‘CUSTOMER COPY’)?>
<?end when?>
<?when:$pCurrentCopy=2?>
<?xdoxslt:set_variable($_XDOCTX, 'wMark', ‘POD’)?>
<?end when?>
<?otherwise:?>
<?xdoxslt:set_variable($_XDOCTX, 'wMark', ‘’)?>
<?end otherwise?>
<?end choose?>
<?end template?>

So on loop 1, I'm setting the watermark for 2nd copy (CUSTOMER COPY).
On loop 2, I'm setting the watermark for 3rd copy (POD)
On loop 3, watermark is set for 1st copy of next invoice (BLANK).

Hope that works for you too.
thanks
J
 
Hey JazNX ;

ok ... so after putting my foot in my mouth yesterday, I've managed to pull it out today with no real damage except a bruise to my ego. Oh well, I'll get over it. Anyway, I found a couple of solutions that really are quite simple. The first does not involve any variables. Just put the following in the text watermark :

<?xdoxslt:ifelse(position()=1,'Canceled','Approved')?>

If you want to use a variable, then try putting the following immediately after the for-each:mad:section:xdoxslt:foreach_number ....

<?variable@incontext:thisposition;position()?>

... and put the following in the text watermark :

<?xdoxslt:ifelse($thisposition=1,'Canceled','Approved')?>


I tested both with all of my 'code' in the document body (nothing in the word header) and it works great. You may get a different result if your looping 'code' is in the word header. Not sure ...

Anyway, with the 'code' in the document body, both of the methods will work and produce 3 copies for each occurance of the group section. The watermark on the first copy will be 'Canceled' and the other 2 copies 'Approved'.

There ... I feel a bit better now.

Cheers !
 
Just to let you know, I tested the same with the 'code' in the header and it works too. Here is the 'code' I have in the header :

<?variable:x:3?>
<?for-each@section:Quote_Supplier_S5?>
<?variable@incontext:currentorder;.?>
<?for-each@section:xdoxslt:foreach_number($_XDOCTX,1,$x,1)?>
<?variable@incontext:wMark;xdoxslt:ifelse(position()=1,’Canceled’,’Approved’)?>

and then, the text in the watermark can be :

<?$wMark?>

and it works great. The only thing is, if you don't have a working 'ifelse' then you will have to find another way of setting the wMark variable.

Cheers
 
Hi Roland
I added the code to the watermark (using ifelse which appears to be ok now); nice I like it.
It works better as well as it works on the current page; not setting it for the next page as mine did.
I can also anchor the totals to the bottom of the page which I couldnt do before without screwing it up.
So nice! Thanks
smile.gif

J
 
Hi Roland,

Can you please share RTF tempalte for reference.

Regards,
Chandan
 
Hi The solution above is working perfectly, but just instead of constant "Cancelled" or "Approved", I'm trying to use a Variable as shown below:

<?for-each@section:xdoxslt:foreach_number($_XDOCTX,1,3, 1)?>
<?end for-each?>
for-each
<?variable@incontext:wMark;xdoxslt:ifelse(position()=2,’DocumentOrder_ID37’, xdoxslt:ifelse(position()=3,’DocumentOrder_ID37’,’BPREX_ORDER_NO_ID335’))?>

but this makes the variable wMark as blank.
I dont understand why this code wont accept variable instead of costant, the same code I replace variables with any constant and it works fine.
Please help if anyone has seen such issue.

Thanks
Ashwin
 
Back
Top