How can i add entitlement inside IT role via rule

Which IIQ version are you inquiring about?

Version 8.3

Share all details related to your problem, including any error messages you may have received.

Hi All, I am able to add IT roles inside business role via rule role.addRequirement(ITROLENAME);. But I don’t know how can I add entitlement inside IT role?. Is there any API or something else by using able to add entitlement.

you can use assignProfiles method from bundle to add entitlements in role. Profile is needs to created based on application name and Constraints and within Constraints you need to set the Filter which is actually filter on entitlement … you can try something like below … its not full and working code but will an idea.

Profile profile = new Profile() ;
profile.setApplication(Application r);
profile.setConstraints(java.util.List<Filter> cons) 
assignProfiles(java.util.List<Profile> profiles)


In assignprofiles if bundle don’t have any profile in list then how can i add new bundle and put that bundle inside assignProfiles as argument.

Hi @amanKsingh

Please find the below code snippet to add profile into an itrole

        profile.setApplication(appObj);
        profile.addConstraint(filter);
        itrole.add(profile);
        context.saveObject(itrole);
        context.commitTransaction();

Hi @amanKsingh ,

Are you using the add method? I am just collating the above scripts.

import java.util.List;

import sailpoint.api.SailPointContext;
import sailpoint.object.Application;
import sailpoint.object.Bundle;
import sailpoint.object.Filter;
import sailpoint.object.Profile;

        Bundle itRole = context.getObjectByName(Bundle.class, <IT Role Name>);
        Filter filter = Filter.contains(<entitlement attribute>, <entitlement value>);
        Application application = context.getObjectByName(Application.class, <application name>);
        Profile newProfile = new Profile();
        newProfile.addConstraint(filter);
        newProfile.setApplication(application);
        itRole.add(newProfile);
        context.saveObject(itRole);
        context.commitTransaction();

Hi @all,

I am using this code create new filter but i want to add inside filter value a list. Is there any method to add filter list inside filter.

for(Profile getprofile:ProfileList){
           System.out.println("600");
            getprofile.addConstraint(filter);
            System.out.println("700");
             //Profile.setApplication(application);
             System.out.println("800");
            // itRole.add(Profile);
            System.out.println("900");
             context.saveObject(itRole);
            System.out.println("1000");
             context.commitTransaction();



OUTPUT:   <Profile created="170922974858847" id="0aaa25248e1e11f581218e2271ac5f3460">
      <ApplicationRef>
        <Reference class="sailpoint.object.Application" id="0aaa250d81af1d0d8181afbdc2e4c001d" name="My_Application"/>
      </ApplicationRef>
      <Constraints>
        <Filter operation="CONTAINS_ALL" property="groups">
          <Value>
            <List>
              <String>cn=*Test,ou=groups,ou=work,dc=test,dc=de</String>
            </List>
          </Value>
        </Filter>
        <Filter operation="CONTAINS_ALL" property="groups">
          <Value>
            <List>
              <String>cn=*Test,ou=groups,ou=work,dc=test,dc=de</String>
            </List>
          </Value>
        </Filter>
      </Constraints>
    </Profile>


**Need output like this:**



<Constraints>
        <Filter operation="CONTAINS_ALL" property="groups">
          <Value>
            <List>
              <String>cn=*Test,ou=groups,ou=work,dc=test,dc=de</String>
              <String>cn=*Test1,ou=groups,ou=work,dc=test,dc=de</String>
            </List>
          </Value>
        </Filter>
      </Constraints>