COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: akustw01 on 28 Apr 2008 11:36:59 AM

Title: Replace images based on report output
Post by: akustw01 on 28 Apr 2008 11:36:59 AM
I am trying to change an image based on the report output.

If a report is PDF, then use this image
else use this different_image.

This is what I have tried.

1. In report studio i add the image object from the insertable objects.

2. Under Properties >> Conditional >> URL Source Variable
I create a boolean Variable, with ReportOutput () in ('PDF')

3. Under Properties >> URL SOURCE
I change the source type to be Report Expression.
I change the report expression to be the following:

IF ( ReportOutput() = 'PDF' ) THEN
    ( <image_source> )
ELSE
    ( <alternate_image_source> )

I have also tried the following

IF ( ReportOutput() = TRUE ) THEN
    ( <image_source> )
ELSE
    ( <alternate_image_source> ).


In concept this seems to work; but in reality it does not.  Any suggestions would be helpful.

Thanks
Title: Re: Replace images based on report output
Post by: almeids on 28 Apr 2008 12:11:34 PM
ReportOutput() returns a string, not a Boolean, so you can't check for the value TRUE.  Try using the comparison ='PDF' (rather than "in") for your boolean variable.
I think conditional formatting/rendering has changed somewhat in C8 but in ReportNet I would put both images on the page and conditionally set their box types to None for true, false values of the variable respectively.
Title: Re: Replace images based on report output
Post by: rockytopmark on 28 Apr 2008 01:09:00 PM
You are on the right track...

How I might do it:

1. Create a Boolean Variable... expression: ReportOutput() = 'PDF'
2. Add a conditional block to the report for housing the images
3. Set the Conditional Block's "Block Variable" to use your boolean variable created in step 1
4. Click the Conditional Block and set the Current Block to No and put the Non-PDF image information in
5. Click the Conditional Block and set the Current Block to Yes and put the PDF image information in
Title: Re: Replace images based on report output
Post by: akustw01 on 28 Apr 2008 01:23:07 PM
rockytopmark,

That worked, Questioned answered and solved. 

Thanks much
Title: Re: Replace images based on report output
Post by: sudha gumpena on 01 May 2008 06:53:28 PM
I was just practicing seeing whats happening in the forums...
i replicated that using boolean ..it worked fine.the pics changed during runtime
but failed while trying do it using string variable.
took 3 pics. it is fine when i declare the variables, saying box type = 'none' , i can see them getting blocked but in the run time it shows all three pics..be it in PDF,Excel & HTML.
do u have a trick to do this with string variable?????
Title: Re: Replace images based on report output
Post by: rockytopmark on 01 May 2008 07:03:21 PM
NO trick... just set up the variable properly.

Variable Expression:  reportOutput()

Values: HTML    PDF     CSV   ....

Each of these values will have a block in the Conditional Block for you to set the proper image on.