Set Entitlement owner to default

So i been trying to set accountgroup owner to default if the group has no owner but the problem is some of them are setting to default but some are not .

import org.apache.log4j.Logger;
  import java.util.Date;
  import sailpoint.object.*;


  import java.util.Calendar;


   Identity id = null;

  //log.error("Obj :: "+obj.toXml());
  //log.error("groupApplication :: "+groupApplication.toXml());
  
   id = context.getObjectByName(Identity.class, "Salesforce Service_1E Default Owner"); 
Identity currentOwner = accountGroup.getOwner();

if(currentOwner == null || currentOwner.isDisabled()){
    accountGroup.setOwner(id);
  }

  return accountGroup;

Hi, after setting the owner you should use:

context.saveObject(accountGroup);
context.commitTransaction();

So that the changes are saved.

@autorun6464
Is this the refresh rule code or a standalone code you are running?

Its a refresh rule code … but looks like its working if i try with detect deleted group option … maybe that could be issue?

Why are you unselecting detect delete in first place, any specific reason? looks for deleted groups in target its not setting because its obvious for those groups this rule will not trigger and your owner will not be set.