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



