During adding entitlement inside IT Role facing issue in script

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.

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>

@amanKsingh

Please paste your code of how you are building the filter Object.

Also can I know the use case behind this , looking at this is a profile object tied to a role, but what is the advantage or use case you need this ?

Check out something similar this this one . for Adding the list of entitlement to the IT role / bundle

// created by Vishal Kejriwal
public void addEntitlementToRole(List entitlements, String application, Bundle bundle) {

  for(int e=0; e < entitlements.size(); e++) {
    Filter f = Filter.eq("groups", entitlements.get(e));
    Profile p = new Profile();
    p.addConstraint(f);
    Application entApplication = context.getObjectByName(Application.class, application);
    p.setApplication(entApplication);
    bundle.add(p);
  }
  context.saveObject(bundle);
  context.commitTransaction();
}

 // Map value contain attribute and name of entitlement
 for (Map.Entry entry : map.entrySet()) {
                         String key = entry.getKey();
                         String value = entry.getValue();
                         System.out.println("Key: " + key + ", Value: " + value);
      
                  String appName="MyApplication";
                  Bundle itRole = context.getObjectByName(Bundle.class, subRoles);
                  
                     
                     
                  
                  Filter filter = Filter.contains(value,key);
                   //  FilterList.add(filter);
                  System.out.println("filter::"+filter);
                  Application application = context.getObjectByName(Application.class, appName);


                  List ProfileList= itRole.getProfiles();
                  System.out.println("ProfileList::"+ProfileList);



                  if(ProfileList.isEmpty()){

                    System.out.println("ProfileList is null");
                   
                    Profile newProfile = new Profile();
                    newProfile.addConstraint(filter);
                    newProfile.setApplication(application);
                    itRole.add(newProfile);
                    context.saveObject(itRole);
                    //context.commitTransaction();  
                    System.out.println("I am creating new profile");
                    
                    

                  }else{
                    System.out.println("Profile exists already");
                    for(Profile getprofile:ProfileList){
                    

                       // System.out.println("getprofile.addConstraint(filter)::: "+getprofile.getConstraints());  
                         System.out.println("Filter value:::"+filter);
                      
                      
                      List GetConstrints_ProfileList=getprofile.getConstraints();
                       System.out.println("GetConstrints_ProfileList::: "+GetConstrints_ProfileList);  
                      
               
                      
                      
                      if (!GetConstrints_ProfileList.contains(filter)) {
            // If not present, add it to the list
                       
                             System.out.println("Filter value:::"+filter);
                       // getprofile.setConstraints(filterValue);
                            getprofile.addConstraint(filter);
                     
                             Profile.setApplication(application);
                          
                              itRole.add(Profile);
                         
                             context.saveObject(itRole);
                        
                         //    context.commitTransaction();
                             System.out.println(" new Entitlement adding done insite IT Role");
           
                       } else {
                               System.out.println(" already exists in the list.");
                              }