Beforeprovisioning rule-salesforce

<?xml version='1.0' encoding='UTF-8'?> This SalesforceProvision rule can to disable the profile when profileid is revoked from sailpoint UAR. <![CDATA[ import java.util.ArrayList; import java.util.List; import sailpoint.object.Identity; import sailpoint.object.ProvisioningPlan.AccountRequest; import sailpoint.object.ProvisioningPlan.AttributeRequest; import sailpoint.object.ProvisioningPlan; import sailpoint.api.Provisioner; import sailpoint.object.*; import sailpoint.tools.Util; import sailpoint.object.ProvisioningPlan.Operation; import sailpoint.object.ProvisioningPlan.AccountRequest.Operation;
    log.info("Inside Rule - BeforeProvisioning - SalesforceBeforeProvisioning");
	
    Identity identity = plan.getIdentity();
    
       if ( plan != null ) {

						   List accounts = plan.getAccountRequests();
								if ( ( accounts != null ) && ( accounts.size() > 0 ) ) {
						  for ( AccountRequest account : accounts ) {
							

							if ( AccountRequest.Operation.Modify.equals( account.getOperation() ) ) {
										 
										  //String nativeIdentity = (String) account.getNativeIdentity();
										
										  AttributeRequest attrReq = account.getAttributeRequest("Profile");
										  
										  AttributeRequest attrReqSpePer = account.getAttributeRequest("Special_Permissions__c");
										  
										  **List<String> SpecialPermissionsList = Arrays.asList(attrReqSpePer.split("\\s*,\\s*"));**
										  
										  List memeberOfListRemoved = new ArrayList();
										  
																		 
													 if ( account != null ) {
													   if ( attrReq != null && ProvisioningPlan.Operation.Remove.equals(attrReq.getOperation()) ) {
														
				                                     if (attrReq.getValue()!=null && attrReq.getValue() instanceof String)
									{
									 account.setOperation(ProvisioningPlan.AccountRequest.Operation.Disable);
									}
									else if (attrReq.getValue()!=null && attrReq.getValue()instanceof List)
									{
									account.setOperation(ProvisioningPlan.AccountRequest.Operation.Disable);
									}

										}
										} 
										
										  if (SpecialPermissionsList != null) {
                  if (SpecialPermissionsList instanceof String) {
                      String strGroup = (String) SpecialPermissionsList;
                      memeberOfListRemoved.add(strGroup);
                  } 
                  else if (SpecialPermissionsList instanceof List) {
                       memeberOfListRemoved = (List) SpecialPermissionsList;
                  }
             }
			 
			   for (Iterator iterator = memeberOfListRemoved.iterator(); iterator.hasNext();){
           
				   String  SpecialPermissions = (String) iterator.next();
				   
				   if (SpecialPermissions != null) {
					   iterator.remove();
					 }
					}
			 
										}  									
										}
						  				}
					   					}

]]>

HI All,

we seeing error in the line below.
List SpecialPermissionsList = Arrays.asList(attrReqSpePer.split(β€œ\s*,\s*”));

we are trying to split special attribute and convert into a list separated by ; .
Can anyone help on this?

Hi @nandiniks,

What is the error you are getting?
attrReqSpePer is String object?
split(β€œ\s*,\s*”) expression will split on commas and consume any spaces either side.

split("\\s*;\\s*") use this express. This will split on semicolon and cousume any spaces either side.

Regards,
Arun

attrReqSpePer is an attribute request object.

attrReqSpePer is AttributeRequest

Hi @nandiniks

Are you using List<String> in your code?

List<String> SpecialPermissionsList = Arrays.asList(attrReqSpePer.split("\\s*,\\s*"));   
Remove the <String> and try. like below
List SpecialPermissionsList = Arrays.asList(attrReqSpePer.split("\\s*,\\s*"));

Hi @nandiniks,

Did you get a chance to update the code and check?

We are seeing still same error Arun.
AttributeRequest object doesn’t have split method?

HI @nandiniks ,

This time you are getting different error could not find method split .
Using split() method, you can split the string.

Try with this

List SpecialPermissionsList = Arrays.asList(attrReqSpePer.toString().split(β€œ\s*,\s*”));

Regards,
Arun

<?xml version='1.0' encoding='UTF-8'?> This SalesforceProvision rule can to disable the profile when profileid is revoked from sailpoint UAR. <![CDATA[ import java.util.ArrayList; import java.util.List; import sailpoint.object.Identity; import sailpoint.object.ProvisioningPlan.AccountRequest; import sailpoint.object.ProvisioningPlan.AttributeRequest; import sailpoint.object.ProvisioningPlan; import sailpoint.api.Provisioner; import sailpoint.object.*; import sailpoint.tools.Util; import sailpoint.object.ProvisioningPlan.Operation; import sailpoint.object.ProvisioningPlan.AccountRequest.Operation;
    log.debug("Inside Rule - BeforeProvisioning - SalesforceBeforeProvisioning");
    Identity identity = plan.getIdentity();
       if ( plan != null ) {

						   List accounts = plan.getAccountRequests();
								if ( ( accounts != null ) && ( accounts.size() > 0 ) ) {
						  for ( AccountRequest account : accounts ) {


							if ( AccountRequest.Operation.Modify.equals( account.getOperation() ) ) {
										  //String nativeIdentity = (String) account.getNativeIdentity();
										  AttributeRequest attrReq = account.getAttributeRequest("Profile");
										  AttributeRequest attrReqSpePer = account.getAttributeRequest("Special_Permissions__c");
										  List SpecialPermissionsList = Arrays.asList(attrReqSpePer.toString().split(β€œ\s*,\s*”));
										  List memeberOfListRemoved = new ArrayList();

													 if ( account != null ) {
													   if ( attrReq != null && ProvisioningPlan.Operation.Remove.equals(attrReq.getOperation()) ) {
				                                     if (attrReq.getValue()!=null && attrReq.getValue() instanceof String)
									{
									 account.setOperation(ProvisioningPlan.AccountRequest.Operation.Disable);
									}
									else if (attrReq.getValue()!=null && attrReq.getValue()instanceof List)
									{
									account.setOperation(ProvisioningPlan.AccountRequest.Operation.Disable);
									}

									}	 
									if ( attrReqSpePer != null && ProvisioningPlan.Operation.Remove.equals(attrReq.getOperation()) ) {
										  if (SpecialPermissionsList != null) {
										  if (SpecialPermissionsList instanceof String) {
											  String strGroup = (String) SpecialPermissionsList;
											  memeberOfListRemoved.add(strGroup);
										  } 
										  else if (SpecialPermissionsList instanceof List) {
											   memeberOfListRemoved = (List) SpecialPermissionsList;
										  }
									 }
									   for (Iterator iterator = memeberOfListRemoved.iterator(); iterator.hasNext();){
										   String  SpecialPermissions = (String) iterator.next();
										   if (SpecialPermissions != null) {
											   iterator.remove();
											 }
											}
											}
											}
										}  									
										}
						  				}
					   					}
										 log.debug("exiting Rule - BeforeProvisioning - SalesforceBeforeProvisioning");

]]>

has context menu

use the standard double quotation marks (" ) on line no:35

List SpecialPermissionsList = Arrays.asList(attrReqSpePer.toString().split("\s*,\s*"));

can you please share the updated line here.

please use the below line which has standard double quotation marks(")

List SpecialPermissionsList = Arrays.asList(attrReqSpePer.toString().split("\s*,\s*"));

Sorry. use the below code

List SpecialPermissionsList = Arrays.asList(attrReqSpePer.toString().split("\\s*,\\s*"));


log.info("Inside Rule - BeforeProvisioning - SalesforceBeforeProvisioning");
	
    Identity identity = plan.getIdentity();
    
       if ( plan != null ) {

						   List accounts = plan.getAccountRequests();
								if ( ( accounts != null ) && ( accounts.size() > 0 ) ) {
						  for ( AccountRequest account : accounts ) {
							

							if ( AccountRequest.Operation.Modify.equals( account.getOperation() ) ) {
										 
										  //String nativeIdentity = (String) account.getNativeIdentity();
										
										  AttributeRequest attrReq = account.getAttributeRequest("Profile");
										  
										  AttributeRequest attrReqSpePer = account.getAttributeRequest("Special_Permissions__c");
										  
										  List SpecialPermissionsList = Arrays.asList(attrReqSpePer.toString().split("\\s*,\\s*"));**
										  
										  List memeberOfListRemoved = new ArrayList();
										  
																		 
													 if ( account != null ) {
													   if ( attrReq != null && ProvisioningPlan.Operation.Remove.equals(attrReq.getOperation()) ) {
														
				                                     if (attrReq.getValue()!=null && attrReq.getValue() instanceof String)
									{
									 account.setOperation(ProvisioningPlan.AccountRequest.Operation.Disable);
									}
									else if (attrReq.getValue()!=null && attrReq.getValue()instanceof List)
									{
									account.setOperation(ProvisioningPlan.AccountRequest.Operation.Disable);
									}

										}
										} 
										
										  if (SpecialPermissionsList != null) {

                  if (SpecialPermissionsList instanceof List) {
                       memeberOfListRemoved = (List) SpecialPermissionsList;
                  }
             }
			 
			   for (Iterator iterator = memeberOfListRemoved.iterator(); iterator.hasNext();){
           
				   String  SpecialPermissions = (String) iterator.next();
				   
				   if (SpecialPermissions != null) {
					   iterator.remove();
					 }
					}
			 
										}  									
										}
						  				}
					   					}

SpecialPermissionsList is List object. No need to check the instanceof String. Try this one