so in this LCM workflow i am trying to auto approve if request is coming from servicenow else gor to manager,owner for approval… i am trying to do it this way but issue is even if request is not from servicenow it is getting autoapprove so what modification do i need to do here
<Variable name="approvalScheme">
<Script>
<Source>
import sailpoint.object.Identity;
import sailpoint.object.Link;
import sailpoint.object.Application;
import sailpoint.api.IdentityService;
import sailpoint.tools.GeneralException;
import java.util.List;
// Define constants
String serviceNowAppType = "ServiceNow"; // Application type for ServiceNow
String approvalScheme = "manager, owner"; // Default approval scheme
String userIdAttribute = "sys_id"; // User ID attribute for ServiceNow
// Fetch the identity object based on identityName
Identity identity = context.getObjectByName(Identity.class, identityName);
if (identity == null) {
throw new GeneralException("Identity not found for identityName: " + identityName);
}
// Check if the request is from ServiceNow
boolean isServiceNowRequest = false;
List links = identity.getLinks();
// Check each link to determine if it's associated with ServiceNow
if (links != null) {
for (Link link : links) {
String appType = link.getApplication().getType();
String appName = link.getApplication().getName();
// Check for both application type and name to confirm it's a ServiceNow request
if ((appType != null && appType.equals(serviceNowAppType)) ||
(appName != null && appName.equals("ServiceNow"))) {
isServiceNowRequest = true;
break; // Stop checking if we've confirmed it's a ServiceNow request
}
}
}
// Set the approval scheme based on whether the request is from ServiceNow
if (isServiceNowRequest) {
approvalScheme = "none"; // Auto-approve for ServiceNow requests
} else {
approvalScheme = "manager, owner"; // Require approval for all other requests
}
return approvalScheme; // Return the final approval scheme
</Source>
</Script>
</Variable>
You need to identify the workflow that runs during the request submission and add the logic for the approval scheme. First, verify whether the flow variable is defined in that workflow. if it is, you can then create logic based on that flow variable.
@autorun6464
How are you calling this workflow from Servicenow , are you using the SCIM API of SailPoint calling LaucnhWorkflows?
If so, you have add a unique key and value in the pay load being passed there which will determine the request is from servicenow and use that variable in the workfllow to set the approvalscheme to none
When you submit a request in ServiceNow, the process initiates a series of actions that integrate with SailPoint using the SCIM API. This integration facilitates the transfer of all relevant details from ServiceNow to SailPoint, effectively launching a workflow based on the specific type of request you submitted.
Within this workflow in SailPoint, you need to set the flow variable to reference the ServiceNow request. Based on the flow varaible, you can add the logic in approval scheme.
If you require additional assistance, please submit a request in ServiceNow and provide the workflow trace.
<Variable name="approvalScheme">
<Script>
<Source>
if (flow != null && flow.equalsIgnoreCase("ServiceNow")) {
return "none"; // Auto-approve for ServiceNow requests
} else {
return "manager, owner"; // Require approval for other requests
}
</Source>
</Script>
</Variable>
but its going for approval for even servicenow request. as of source and flow i got tgwo of these variable defined if you think i should be changing based on these?
<Variable input="true" name="flow">
<Description>The name of the LCM flow that launched this workflow.
This is one of these three values:
AccountsRequest
EntitlementsRequest
RolesRequest</Description>
</Variable>
<Variable initializer="LCM" input="true" name="source">
@autorun6464
Dont approve anything and once the request is created, share the workflow case, also do you have the payload being passed from Servicenow for this workflow invocation
This is an out-of-the-box (OOTB) LCM Provisioning workflow. It will be triggered when you submit a request from SailPoint. When you raise a request in ServiceNow, it will send the necessary information to SailPoint to execute the defined workflow.
this is my workflow case .but strange thing i notice was in flow.equals(“ServiceNow”) i had this but some how it showing workflow cas ("UnlockAccount servicenow request.txt (82.9 KB)
")
@autorun6464
I dont see any attribute in your workflow case that can be distinguished as the request is from Servicenow, Please get the payload that is being used at servicenow end to create request in Sailpoint , you have to modify the payload from thier accordingly and add condition in workflow.
@autorun6464
I dont think we can do much here with workflowcase as mentioned earlier because there is no specific attribute you are passing from Servicenow , usually people will set either flow or atleast comments in the plan with RITM details, in your case, I dont see anything to distinguish the request is coming from servicenow, thats the reason if you can get the payload being used by Servicenow team to call the launch workflow , will check that and see if there is anything that you can use in your workflow
how can i get that payload??like how do i check it . i also wanted to check what payload servicenow is passing to sailpoint while triggering theworkflow.