HI
The provisioning rule outlined below is based on the following two points. However, it appears that the code is being skipped, resulting in no updates to the target. Is there any issue in the rule.
-
Sync should occur only when
emailAddris not blank and notNO_EMAIL. -
when the request is modified
emailAddr,oprid anddestEmailAddr = @@testnet.test.asin
import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.ProvisioningPlan.AttributeRequest;
import sailpoint.object.Application;
import sailpoint.object.Identity;
import sailpoint.connector.Connector;
import java.util.List;
import java.util.ArrayList;
log.info("Before Provisioning Rule: Validate Email Start");
if (plan != null && plan.getAccountRequests() != null) {
List accountRequests = plan.getAccountRequests();
List requestsToRemove = new ArrayList();
for (Object accReqObj : accountRequests) {
AccountRequest accReq = (AccountRequest)accReqObj;
boolean removeThisRequest = false;
String removalReason = "";
if (AccountRequest.Operation.Create.equals(accReq.getOperation()) || AccountRequest.Operation.Modify.equals(accReq.getOperation())) {
AttributeRequest emailAttrReq = accReq.getAttributeRequest("emailAddr");
if (emailAttrReq != null && emailAttrReq.getValue() instanceof String && "NO_EMAIL".equalsIgnoreCase((String)emailAttrReq.getValue())) {
removeThisRequest = true;
removalReason = "emailAddr attribute value is 'NO_EMAIL'";
} else {
if (emailAttrReq == null) {
removeThisRequest = true;
removalReason = "Mandatory emailAddr attribute is missing";
} else {
Object emailValue = emailAttrReq.getValue();
boolean valueIsInvalid = false;
if (emailValue == null) {
valueIsInvalid = true;
} else if (emailValue instanceof String) {
if (((String)emailValue).trim().isEmpty()) {
valueIsInvalid = true;
}
}
if (valueIsInvalid) {
removeThisRequest = true;
removalReason = "Mandatory emailAddr attribute value is null or empty after cleanup";
} else {
// -------------------------------------------------------
// NEW LOGIC: Email is valid
// -------------------------------------------------------
Identity identity = plan.getIdentity();
if (identity != null) {
// 1. Retrieve Attributes from Identity
String uid = identity.getStringAttribute("uid");
String oprid = identity.getStringAttribute("oprid");
// 2. Construct destEmailAddr ($uid@mednet.test.asin)
if (uid != null) {
String destEmailAddr = uid + "@testnet.test.asin";
// Add to Plan (Operation.Set ensures it is sent)
accReq.add(new AttributeRequest("destEmailAddr", ProvisioningPlan.Operation.Set, destEmailAddr));
} else {
log.warn("Rule HCMWriteBack: 'uid' attribute is missing for identity " + identity.getName());
}
// 3. Add oprid to Plan
if (oprid != null) {
accReq.add(new AttributeRequest("oprid", ProvisioningPlan.Operation.Set, oprid));
} else {
log.warn("Rule testkrule: 'oprid' attribute is missing for identity " + identity.getName());
}
// Note: emailAddr is already present as 'emailAttrReq'
} else {
log.warn("Rule BRBack: Could not retrieve Identity object from Plan.");
}
}
}
}
if (removeThisRequest) {
log.error("Marking AccountRequest for '" + accReq.getNativeIdentity() + "' for removal from plan. Reason: " + removalReason);
requestsToRemove.add(accReq);
}
}
}
if (!requestsToRemove.isEmpty()) {
log.info("Removing " + requestsToRemove.size() + " account requests from the provisioning plan.");
accountRequests.removeAll(requestsToRemove);
}
} else {
log.info("Plan is null or has no requests.");
}
log.info("Before Provisioning Rule: Validate Email and Filter Plan End");