Hello Experts,
I build my very first Before Provisioning Rule for a webservice application. I will be just syncing the data from ISC to Webservice application, but i need to send 4 different payload with a PATCH Method.
- add email
- update email
- add phone
- update phone
I created 4 different http operation and thought of write a BeforeProvisioning rule that will select the operation when syncing is happening.
Here is the first rule I generated, your feedbacks will be very helpful.
import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.ProvisioningPlan.AccountRequest.Operation;
import sailpoint.object.ProvisioningPlan.AttributeRequest;
import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningPlan.Operation;
import sailpoint.object.Identity;
if (plan != null && plan.getAccountRequests() != null) {
for (AccountRequest accReq : plan.getAccountRequests()) {
if ("WebApp".equalsIgnoreCase(accReq.getApplicationName())
&& accReq.getOperation() == AccountRequest.Operation.Modify) {
Map<String, Object> currentAttributes = accReq.getNativeIdentity() != null ? accReq.getAttributes() : new HashMap<>();
String currentEmail = currentAttributes.containsKey("secondaryEmail") ? (String) currentAttributes.get("secondaryEmail") : null;
AttributeRequest emailAttrReq = accReq.getAttributeRequest("secondaryEmail");
String newEmail = emailAttrReq != null ? (String) emailAttrReq.getValue() : null;
if (newEmail != null) {
accReq.setOperation((currentEmail == null || currentEmail.isEmpty())
? AccountRequest.Operation.Add : AccountRequest.Operation.Modify);
}
String currentPhone = currentAttributes.containsKey("phoneCallCell1") ? (String) currentAttributes.get("phoneCallCell1") : null;
AttributeRequest phoneAttrReq = accReq.getAttributeRequest("phoneCallCell1");
String newPhone = phoneAttrReq != null ? (String) phoneAttrReq.getValue() : null;
if (newPhone != null) {
accReq.setOperation((currentPhone == null || currentPhone.isEmpty())
? AccountRequest.Operation.Add : AccountRequest.Operation.Modify);
}
}
}
}
Thank you
Learning ISC daily