When using rapidsetup, there are cases when u use post actions to be run such as delete account on leaver after X days which uses the deferred tasks capabiliy.

in some cases you need to delete the task before it is run. for example leaver process who initiate post deletion task but employee has return to work and u need to stop the task from running.

following rule will delete deferred tasks for specific user.


<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">

<Rule created="1388673847625" language="beanshell" modified="1722514696999" name="delete deferred leaver task" significantModified="1722514696999" type="ActivityCorrelation">

  <Description>Rule to show how an CEF activity might be correlated back to an identity. In most cases, this rule will be providing enought information to the correlator so that it can find the Application link. In some cases, it might also be desireable to return something that points back to an Identity, which is also supported.</Description>

  <Signature returnType="Map">

    <Inputs>

      <Argument name="log">

        <Description>

          The log object associated with the SailPointContext.

        </Description>

      </Argument>

      <Argument name="identityName">

        <Description>

          The log object associated with the SailPointContext.

        </Description>

      </Argument>

      <Argument name="context">

        <Description>

          A sailpoint.api.SailPointContext object that can be used to query the database if necessary.

        </Description>

      </Argument>

      <Argument name="application">

        <Description>

          The application where the activity was generated.

          An application may have more then one data source.

        </Description>

      </Argument>

      <Argument name="datasource">

        <Description>

          The data source that returned the activity.

        </Description>

      </Argument>

      <Argument name="activity">

        <Description>

          The activity object that was normalized by

          the data source and that we are trying to

          correlate back to one of our Identities.

        </Description>

      </Argument>

    </Inputs>

  </Signature>

  <Source>

  import sailpoint.object.Identity;

    import sailpoint.api.Terminator;

  import sailpoint.object.QueryOptions;

  import sailpoint.object.Filter;

  import sailpoint.object.Filter.MatchMode;

  import sailpoint.object.Request;


  log.error("start rule");

 


/**

Get the Request object(s) used to delete/disable a user that get created due to the leaver process

*/

  //List&lt;Request> getDeferredLeaverRequest() 

  

  {

    //    log.error("in function start");

  //  for debuging u can enter manualy user

    //  String identityName="Aaron.Nichols";

    Identity iden = context.getObjectByName(Identity.class, identityName);




    //log.error("Searching for Deferred Leaver Request"); u can add filter for any other deferred task you wich by names

    List&lt;Request> list = new ArrayList&lt;Request>();


  log.error("before filter param");

  

    Filter owner = Filter.eq("owner", iden);

    Filter nameDeferred = Filter.like("name", "Deferred Leaver Request", MatchMode.START);

    Filter filterDeferred = Filter.and(owner, nameDeferred);


 //   log.error("after filter param");

    

    Filter finalFilter = Filter.or(filterDeferred);

    

    QueryOptions qo = new QueryOptions();

    qo.add(finalFilter);



    Iterator iterator = null;

    try {

        

        iterator = context.search(Request.class, qo);

    //        log.error("after query");

        while (iterator.hasNext()) {

            Object next = iterator.next();

            

            list.add((Request)next);

        

        }


    } catch (Exception e) {

        log.error("Exception during getDeferredLeaverRequest()", e);

    } finally {

        if (iterator != null) {

            sailpoint.tools.Util.flushIterator(iterator);

        }

        

    }

    

  

//List&lt;Request> listDef = list;

// log.error("before FOR list="+list.size());

    Terminator terminator = new Terminator(context);

        for (Request req : list) {

      try{

        terminator.deleteObject(req);

      }

      catch (Exception e) {

        logger.error("Exception during delete deferred task ()", e);

    

        }

    

  

      return list;



}


  </Source>

</Rule>