I have this requirement to remove classification on groups.
I am using beanshell code in the Workflow step to add the classification and it’s working fine for me
but while I try to remove them, it gives me unknown null error.
Any suggestion will be appreciated.
Below is the code which I am using to remove classification.
The issue you are facing is that you are removing objects from the list in a for-loop which brakes the for-loop.
The solution, store what you want to remove in a separate list in the for-loop and start a new for-loop over the separated list to perform the actual removal.
import sailpoint.object.ManagedAttribute;
import sailpoint.object.Classification;
import sailpoint.object.ObjectClassification;
ManagedAttribute ma = context.getObjectByName(ManagedAttribute.class,"example");
if(ma != null ) {
List<ObjectClassification> objClass = ma.getclassifications();
List<ObjectClassification> toBeRemoved = new ArrayList();
for (ObjectClassification objC : objClass) {
toBeRemoved.add(objC);
}
for (ObjectClassification objC : objClass) {
ma.removeClassification(objC);
}
if (log.isDebugEnabled()) log.debug(ma.toXml());
context.saveObject(ma);
context.commitTransaction();
}