Delete role via Rule including child objects

Hi All,

I am trying to delete a role using below code and gets a constraint error. I know IT roles has profiles and the error is related to complaining about the child records. What is the best to do a cascade delete of a role.

The conflict occurred in database “identityiq”, table “identityiq.spt_profile”, column ‘bundle_id’.


Scope scope = context.getObjectByName(Scope.class, project);
if (scope != null) {
QueryOptions qo = new QueryOptions();
qo.addFilter(Filter.eq(“assignedScope.id”, scope.getId()));
context.removeObjects(Bundle.class, qo);
context.commitTransaction();
}


Thanks in Advance

@venus

For future reference, this should be posted under IdentityIQ, not IdentityNow.

You should use the sailpoint.api.Terminator class to delete objects in IdentityIQ. This ensures referential integrity is taken into account:

Terminator t = new Terminator(context);
t.deleteObject(object);

1 Like

Thanks a lot Paul, will try this today.

Works like a charm, thank a lot Paul again.

@paul_wheeler, I moved this topic to the IIQ category. Thanks for catching it.

@venus I am using the following rule to execute a mass role deletion to be speicifc there are about 80k roles that needs to be deleted. I am using a run rule task and It takes about a day for the task to run and deletes about 500 roles and then either terminates itself or gives out an error - Can you please help me with what you exactly did and it worked for you?
Here is the code being used -

String ROLE_SUFFIX = “Role Ark”; //Name of the role goes here
int rolecount = 0;
Filter filter = Filter.and(Filter.like(“name”, ROLE_SUFFIX, Filter.MatchMode.START));
QueryOptions qo = new QueryOptions();
qo.addFilter(filter);
IncrementalObjectIterator iOitr = new IncrementalObjectIterator(context, Bundle.class, qo);
while(iOitr.hasNext()){
rolecount = rolecount + 1;
Bundle role = iOitr.next();
Terminator term = new Terminator(context);
term.deleteObject(role);
}