Here email is being send even if account creation is failed.. here i check if account is successfully created before seding email

import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningResult;
import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.ProvisioningPlan.AttributeRequest;
import sailpoint.object.*;
import sailpoint.api.Provisioner;
import sailpoint.object.ProvisioningProject;
import sailpoint.object.Identity;
import sailpoint.object.*;
import sailpoint.tools.Util;
import org.apache.log4j.Logger;
import sailpoint.object.EmailFileAttachment;
import sailpoint.object.EmailOptions;
import sailpoint.object.EmailTemplate;
import sailpoint.tools.EmailException;
import java.util.List;
import sailpoint.workflow.StandardWorkflowHandler;
import sailpoint.workflow.WorkflowContext;
import sailpoint.api.Workflower;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;
Logger logger = Logger.getLogger("AIZRules.racfAfter");
logger.debug("ENTRY : AIZ-RACF-After-Provisioning for " + plan.getNativeIdentity());
logger.debug("Initial Plan is " + plan.toXml());
List accReqList = plan.getAccountRequests(application.getName());
logger.info("accReqList are " + accReqList);
String identityName = plan.getNativeIdentity();
String pwdRACF = null;
if (accReqList != null) {
    for (ProvisioningPlan.AccountRequest accRequest: accReqList) {
        if (accRequest != null & amp; & amp; AccountRequest.Operation.Create.equals(accRequest.getOperation())) {
            String nativeId = plan.getNativeIdentity();
            log.error("The identityName is[" + nativeId + "]");
            if (nativeId != null) {
                Identity identityObject = context.getObjectByName(Identity.class, nativeId);
                AttributeRequest pwdAttrReq = accRequest.getAttributeRequest("password");
                String pwdAttrReqValue = pwdAttrReq.getValue();
                logger.info("pwdAttrReqValue is " + pwdAttrReqValue);
                // user.setName(nativeId);
                //  user.setLastname(pwdAttrReqValue);
                sendRACFNewUserNotificationToManager(identityName, pwdAttrReqValue);
                // sendRehireNotificationToManager(identityName);
            }
        }
    }
}

The connector returns a ProvisioningResult object, which will be stored at one of two places, depending on the connector. You can get it either from the ProvisioningPlan (plan.getResult()) or from the AccountRequest.

Once you have that object, it has an isCommitted() method, which will return true if the provisioning was successful.

check this code snippet

          if(accountRequest != null && accountRequest.getResult().getStatus().equalsIgnoreCase("Committed")){
// send email
}
2 Likes

thanx a lot it helped

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.