Manager Approval Not Going

Hi all in my workflow i am sending approval to the manager after generating the username of the user
it has steps like a form which has first name last name etc and then next step is map output which fetches and stores these attributes and the next step is of username which is also getting generated
next step is to send this for manager approval which is not going

Map output code 

import sailpoint.object.Identity;
 
log.error("Fetching Identities ==");
 
// Helper method to safely fetch a field's value

String safeGetValue(String fieldName) {

    if (workItemForm.getField(fieldName) != null && workItemForm.getField(fieldName).getValue() != null) {

        return workItemForm.getField(fieldName).getValue().toString();

    } else {

        log.error("Form field '" + fieldName + "' is missing or null!");

        return "";

    }

}
 
// Fetching values safely

String expiryDate = safeGetValue("expiryDate");

String comment    = safeGetValue("comments");

String managerId  = safeGetValue("manager");   // Identity ID

String firstname  = safeGetValue("firstname");

String lastname   = safeGetValue("lastname");

String phoneno    = safeGetValue("phoneno");
 
// Generate identity name (e.g., ajay.pratap)

String identityName = firstname.toLowerCase() + "." + lastname.toLowerCase();
 
// Try resolving manager Identity object

Identity mgrObj = null;

String managerName = "";
 
if (managerId != null && !managerId.trim().isEmpty()) {

    mgrObj = context.getObjectById(Identity.class, managerId);

    if (mgrObj != null) {

        managerName = mgrObj.getDisplayName();

        workflow.put("manager", mgrObj); //  Store full Identity object for approval step

        workflow.put("managerName", managerName); // optional: readable name

        log.error("Resolved and stored manager: " + managerName);

    } else {

        log.error("Manager ID provided but no Identity found: " + managerId);

    }

} else {

    log.error("Manager field was empty or invalid.");

}
 
// Logging

log.error("workItemForm - identityName    = " + identityName);

log.error("workItemForm - AccountExpiry   = " + expiryDate);

log.error("workItemForm - comment         = " + comment);

log.error("workItemForm - manager name    = " + managerName);

log.error("workItemForm - firstname       = " + firstname);

log.error("workItemForm - lastname        = " + lastname);

log.error("workItemForm - phoneno         = " + phoneno);
 
// Storing in workflow

workflow.put("identityName", identityName);

workflow.put("AccountExpiry", expiryDate);

workflow.put("comment", comment);

workflow.put("firstname", firstname);

workflow.put("lastname", lastname);

workflow.put("phoneno", phoneno);
 
 
return true;

Manager Approval Step Code is this:

import sailpoint.object.Identity;

import sailpoint.object.Workflow.Approval;

import java.util.*;
 
log.debug("=== ApprovalAssignment - Manager Only ===");
 
// Retrieve workflow variables

String identityName = workflow.get("identityName");

String launcher = workflow.get("launcher");

log.error("identityName: " + identityName);

log.error("launcher: " + launcher);
 
// Result list

List<Approval> newApprovals = new ArrayList<Approval>();
 
if (identityName != null) {

    Identity identity = context.getObjectByName(Identity.class, identityName);

    if (identity != null && identity.getManager() != null) {

        Identity manager = identity.getManager();
 
        // Avoid self-approval

        if (!manager.getName().equalsIgnoreCase(launcher)) {

            log.debug("Assigning approval to manager: " + manager.getName());
 
            // Create new approval object

            Approval approval = new Approval();

            approval.setApprover(manager.getName());

            approval.setName("Manager Approval");

            // approval.setApprovalSet(approvalSet); // optional: remove if not defined

            newApprovals.add(approval);

        } else {

            log.error("Manager is same as launcher. Skipping approval assignment.");

        }

    } else {

        log.error("Identity or manager not found for identityName: " + identityName);

    }

} else {

    log.error("identityName is null");

}
 
return newApprovals;

manager approval
 
1 Like

Hi @Viraj are you using LCM Provisioning for the provided use case for provisioning? if you use the LCM provisioning then add approval scheme values as manager. Please share more info about your usecase.

yes by use of lcm provisioning i want but how can i send it for approvals.i will call it as a subprocess


And approvals aint reaching manager

Hii @Viraj

No need for adding an extra manager approval step. In lcm provisioning we can achieve that as shown in the figure in lcm provisioning process variables tab we have approvers there you can add manager, owner and other identitiy if you want

no need of manager approval step and level2 approval step directly connect it to the build plan step, LCM Provisioning will take care of it.

Note: Create a new LCM Provisioning workflow don’t disturb the OOTB LCM Provisioning workflow as it is used by LCM and Non LCM events, the best practise is to create a new LCM Provisioning workflow for that you can simply go and click on save as and give the custom name and refer that in the subprocess of your workflow.

1 Like

Hi Viraj Welcome to Sailpoint Developer Community
For your use case you donot require multiple approval steps as added
Simply you can duplicate LCM provisoning and can call it as a subprocess
while provisoning
In This Duplicated workflow You can add approvers by opening the business process and then selecting it and going to process varialbles under there you will find approval now u have these options whether 1)Owner 2)Manager 3)Security Groups of particular identities
After selecting the approvers you can directly link your workflow


Hope this works !

1 Like

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