Wednesday 8 July 2020

Rules in Sailpoint

Rules are the construct through which IdentityIQ allows the addition of custom business logic at specific points within the execution flow of the product.

The below is the sample how to construct business logic, There are multiple application on-board to Sailpoint and the requirement is to get the mail of the user from an specific application HR System – Employees.


The below are the learning

1.
       How can we define a method in Rule (A Java method is a collection of statements that are grouped together to perform an operation.)
2.
       Link of an identity
3.
       How to test the rule in IIQ console



Code

      import sailpoint.object.Identity;
 import java.util.*;
 import sailpoint.api.*;
 import sailpoint.object.Link;
// Java Method
 
 public static String GetEmail(String user) {

 
 Identity id = context.getObject(Identity.class,user);
 List listOfLinks=id.getLinks();
 if(listOfLinks!=null){
                        for(Link link : listOfLinks)
                               {
                               if(link.getApplicationName().equals("HR System - Employees")){
                                 String emailofApp = link.getAttribute("email");
                                 return emailofApp;
                                }
                            }
                        }
                                           }


     String user = "Adam.Kennedy";
String emailofuser = GetEmail(user);   // Calling the Method
System.out.println("We have found the email of the user"+ " "+ emailofuser);

Save the above code in a Rule.
In IIQ Console.






Thursday 2 July 2020

How to get the value of other fields in a form in validation scripts.

I have two fields Location & sub-location and based on the value in location, the sublocation should allow to have the value from selected value from the lists and on having a different value in the field should give the customized message.

Eg,    Location India and corresponding sublocation is Bangalore,Hyderabad,Pune




The below rule can have multiple If statement, based on your requirement.





//validation variable comes in as 'value'
                import sailpoint.tools.Message;
                String Val = form.getField("Location").getValue();
                System.out.println("Value is :" + Val);
                List messages = new ArrayList();
                String input = (String)value;
                System.out.println("Value :" + input);
// Check===================================
   if(Val.equals("India")) {
   List loc = new ArrayList();
     loc.add("Bangalore");
     loc.add("Pune");
     loc.add("Hyderabad");
        int j=0;   
     for(String item : loc){
       if( input.equals(item)){
            j++;       

                   }          
        }               

      if(j!=1) {
                Message msg = new Message();
                     msg.setKey("Allowed value are Bangalore,Pune,Hyderabad");
                     messages.add(msg);

                }       

          }
     return messages;

ServiceNow onboarding Sailpoint