Share all details about your problem, including any error messages you may have received.
We have an approvalAssignmentRule in the LCM Provisioning workflow that works as intended when adding (requesting) a role.
This rule is also unfortunately triggering when removing a role from a user, we don’t want the approval logic to effect removal requests.
We tried returning null in the approval list, but that even removes the request operations and everything involved. Looking to see if this is something someone has working for them.
In the approval assignment rule, you will get the approval set which contains all the required approval. We can iterate through the all items, check if it is for remove then mark it finished and then removed from the original approval set.
try the below sample code
List originalItems = approvalSet.getItems();
List itemsToRemove = new ArrayList();
for(ApprovalItem curritem: originalItems){
if (curritem.getOperation().equalsIgnoreCase("Remove")) {
curritem.approve();
curritem.setState(WorkItem.State.Finished);
curritem.setOwner("spadmin");
itemsToRemove.add(curritem);
}
}
log.error( "Done modified approvalSet is :"+itemsToRemove);
if(!Util.isEmpty(itemsToRemove)){
if(!(itemsToRemove.size() == originalItems.size() && itemsToRemove.containsAll(originalItems) && originalItems.containsAll(itemsToRemove))) {
for(ApprovalItem curritem: itemsToRemove){
approvalSet.remove(curritem);
}
}
}
log.error( "modified approvalSet is" + approvalSet.toXml());