Trying to learn rules but a simple one is not working!

Hi

I am using v8.3 and I am new to Java/beanshell. I am trying to write a new simple print statement but its showing blank screen !

Could you advise please whats wrong here ?

Also could you please tell me best resource how to learn beanshell/rules ?

Thanks !

log.error() - this will print the logs in log file , in case you want to see output on UI , return the variable .
For Example -
return firstname;

1 Like

Refer below link for Rules -

https://community.sailpoint.com/t5/Technical-White-Papers/Rules-in-IdentityIQ/ta-p/78176

No effect :frowning:

Hi @noob_iiq can you once validate the rule name that you are running

Are you selecting rule when running , refer below screenshot , you have to select rule there which you want to run -


1 Like

Yes I am running like this Harsh, rule is selected and then run rule is clicked !

This will not work , in Run rule box , enter your rule name , it will come in to dropdown . select that and hit run rule button.

@noob_iiq , refer above screenshot.

1 Like

OMG ! it runs..you have to put in searchbox and then it runs only. This is crazzy man ! selecting checkbox doesnt run rule :rofl:

Thanks Harsh !

Good to know , Long Path but you will be there . Keep Learning . :slight_smile:

1 Like

Hi!

You’re currently using log.error() in your BeanShell script, which writes messages to the server logs (like catalina.out if you’re using Tomcat). That’s why you’re seeing a blank screen—it’s not designed to display output in the UI.

To show output on the screen:

Use a return statement instead:

return firstname;

Best Resource to Learn BeanShell and Rules:

https://community.sailpoint.com/t5/Technical-White-Papers/BeanShell-Developer-s-Guide-for-IdentityIQ/ta-p/74365

1 Like

One more q :

costcenter is an extended attribute, but why its not returning anything ?

HI @noob_iiq , You have two return statement , code exited in first return statement itself , thats why its not going to 2nd return statement costcenter one.
comment first return statement . it will work.
Thanks.

oh strange, does that mean only one return statement works ? What if I want to print all attributes say firstname,email and costcenter one by one ?

Hi @noob_iiq,

When writing BeanShell code in a Rule object on the debug page of SailPoint IdentityIQ, you’re limited to using only one return statement. This means:

  • You cannot print multiple attributes using return, because once the return statement executes, the script exits.
  • If you try to return multiple values or print multiple lines, only the first one will be executed.

To work around this limitation and still inspect multiple attributes, you should use the Apache Log4j logging framework, which is integrated into IdentityIQ. This allows you to log as many values as you need before the script exits.

It’s not a limitation or strange behaviour . I would recommend to explore Core Java , it will help you in writing code .
You can create a string and append all the variable which you want to see as per your format . And return that string .