0
IF($F{Status} == "Lopend" ,$P{IMG_DIR} + "scorm_incomplete.png", ""
,OR($F{Status} == "Voltooid", $P{IMG_DIR} + "scorm_completed.png","", 
OR($F{Status} == "Niet geprobeerd", $P{IMG_DIR} + "scorm_not_attempted.png", "" )))

I am working with jaspersoft for creating a rapport for tests on a E-Learning website,

but with the status for the tests he should give an icon...

but this Statement doesn't work on Jaspersoft...

the error I am getting is:

The method OR(Boolean...) in the type LogicalFunctions is not applicable for the arguments (Boolean, String, String)

does anybody knows the solution?

(Sorry for my bad english..)

Alex K
  • 22,315
  • 19
  • 108
  • 236
jkieboom
  • 5
  • 4

2 Answers2

0

First, the OR() function should be used with Booleans. Your error is talking about this line:

OR($F{Status} == "Niet geprobeerd", $P{IMG_DIR} + "scorm_not_attempted.png", "" )

Make the Strings into Booleans. For example $P{IMG_DIR} + "scorm_not_attempted.png" != "BadFooBarscorm_not_attempted.png" to check that the image is not a certain image.

Why the error? Because OR() is used to return a TRUE or FALSE if one of the inputs is TRUE. A String can't be evaluated to TRUE or FALSE, so the OR() throws an error. Your OR() here has 3 inputs, and only one is actually going to work.

$F{Status} == "Niet geprobeerd", 

returns a Boolean (either TRUE or FALSE)

$P{IMG_DIR} + "scorm_not_attempted.png", 

returns a String (FOOBARscorm_not_attempted.png)

""

returns a String ()

Second, your OR() statement that threw the error is nested in another incorrect OR() statement:

OR($F{Status} == "Voltooid", $P{IMG_DIR} + "scorm_completed.png","", 
OR($F{Status} == "Niet geprobeerd", $P{IMG_DIR} + "scorm_not_attempted.png", "" ))

You need to do the same thing with this one. What you have right now is OR(Boolean, String, String, Boolean) and it needs to be OR(Boolean, Boolean, Boolean, Boolean)

It also looks like you will have trouble with the IF() statement after you fix the OR()s. Can you give more details about what you want this expression to do? What are the OR() statements checking for? What is supposed to display when the status is "Voltooid"? Etc.

(Sorry, I wish I spoke Dutch)

0

Please, be more precise on your need.

For what I see, you have trouble with the IF syntax and the OR isn't needed here. The correct syntax is

IF(condition, returned value if condition true, returned value if condition false)

You can use the false clause to check different cases. From the information you gave, the correct answer to your problem is

IF($F{Status} == "Lopend", $P{IMG_DIR} + "scorm_incomplete.png", IF($F{Status} == "Voltooid", $P{IMG_DIR} + "scorm_completed.png", IF($F{Status} == "Niet geprobeerd", $P{IMG_DIR} + "scorm_not_attempted.png", "")))

Also, prefer the .equals() method than == to compare the Strings. == will return true only if it is the same instance, .equals() compare if each character of the two Strings are the same. For more information, please do check this topic. The result is :

IF($F{Status}.equals("Lopend"), $P{IMG_DIR} + "scorm_incomplete.png", IF($F{Status}.equals("Voltooid"), $P{IMG_DIR} + "scorm_completed.png", IF($F{Status}.equals("Niet geprobeerd"), $P{IMG_DIR} + "scorm_not_attempted.png", "")))

Finally, OR() statement can be used for the condition. For example :

IF(OR($P{DUMMY}.equals("test1"),$P{DUMMY}.equals("test2")), <true clause>, <false clause>)
Axiome
  • 695
  • 5
  • 18