Running Task From Rule

Which IIQ version are you inquiring about?

Version 8.3

Share all details related to your problem, including any error messages you may have received.

Good afternoon!

Hopefully this is a simple question. My goal is to execute a task via a custom rule. I found some examples where you can create a task schedule and execute the task that way, but I’m hoping there’s some way to pass in, say, a filter to the task.

The task I have in mind is the Prune Identity Cubes task. Currently, we use that singular task with a filter (such as name==SomeName) to prune single identity cubes, and it works just fine. I’m hoping to write a rule that does several things: delete all the links for an identity, set the useBy preference to nothing, commit these transactions, and then prune the cube. So far, i’ve got 3 out of the 4 objectives ready, but I can’t quite figure out the pruning part. Is it possible to set a filter on a TaskDefinition object via a custom rule?

Hi @RSanders

I have done this couple of years back, you can use the below code.

It will create Task Result object for each and every identity, you need to add additional code to delete them if you don’t want.

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule language="beanshell" name="Main-Prune">
  <Source>
  import java.util.Map;
  import java.util.List;
  import sailpoint.object.Identity;
  import sailpoint.object.QueryOptions;
  import sailpoint.object.Filter;
  import sailpoint.api.TaskManager;
  import sailpoint.object.TaskResult;

  QueryOptions qo = new QueryOptions();
  Filter f1 = Filter.eq("correlated", false);
  qo.addFilter(f1);

  List idList = context.getObjects(Identity.class, qo);

  for(Identity id : idList){
    log.error("Pruning identity::"+id.getName());
    Map map = new HashMap();
    String filter = "name == \""+id.getName()+"\"";

    map.put("filter", filter);

    try {
      TaskManager tm = new TaskManager(context);
      TaskResult result = tm.runSync("Prune Identity Cubes", map);
    } catch (Exception e) {
      log.error("Exception pruning identity::"+id.getName());
    }
  }
  </Source>
</Rule>

Thanks
Krish

Ah! That looks promising. I will give that a try and see how it goes.

Thanks!

Finally found some time to test this out, and it works great! Thanks so much!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.