Search This Blog

Showing posts with label TaskDefinition. Show all posts
Showing posts with label TaskDefinition. Show all posts

Friday, June 5, 2020

Customizing SailPoint Task Definitions - Run with Response

Subject: Batch Processing in SailPoint

Regarding: Adding responses to a batch process using Run Rule

Creating a TaskDefinition for running a rule is normally performed by the following:

Setup -> Tasks
New Task -> Run Rule

Enter the details such as what you want the rule to be named, description, then the rule to be executed.  Save and Run


Once you have done this, you will have a framework TaskDefinition with the following elements:

<Attributes>
  <Map>
    <entry key="ruleName" value="the rule you chose"/>
  </Map>
</Attributes>

and also:

<Parent>
  <Reference class="sailpoint.object.TaskDefinition" name="Run Rule"/>
</Parent>

You may want to output some results.  The issue with this is that the Run Rule normally does not have a section for outputs.

To fix this you can add the following elements:

<Signature>
  <Returns>
    <Argument name="totalCount" type="int">
      <Prompt>Total users processed</Prompt>
    </Argument>
    <Argument name="resultString" type="string">
      <Prompt>Results:</Prompt>
    </Argument>
  </Returns>
</Signature>

You also can add this to a clone of Run Rule and use that as a template for new rules.  But this does not populate the values.
 
To populate the values, the following is needed in the rule:
 
 (imports)
import sailpoint.tools.Message;
import sailpoint.tools.Message.Type;
import sailpoint.object.Attributes;
import sailpoint.object.TaskResult;
import sailpoint.object.TaskResult.CompletionStatus;

variables:
int resultCount=0;
String resultString="";

Set these values in your code.

Then just before the return:

if(taskResult!=void) {
  taskResult.addMessage(new Message(Message.Type.Info,"Completed Successfully", null));
  Attributes resultAttr=new Attributes();
  resultAttr.put("totalCount",new Integer(resultCount));
  resultAttr.put("resultString",resultString);
  taskResult.setAttributes(resultAttr);
  taskResult.setCompletionStatus(TaskResult.CompletionStatus.Success);
}

I use a StringBuffer instead of concatenating the resultString, and then set resultString to the toString() result of the StringBuffer.


Inputs:

If you want to add inputs to the Run Rule task definition, you would need to start by pulling the signature inputs from Run Rule.  From there you can add fields as you would any TaskDefinition.

For example:

<Signature>
  <Inputs>
    <Argument helpKey="help_task_run_rule_rule" name="ruleName" required="true" type="Rule">
      <Prompt>label_rule</Prompt>
    </Argument>
    <Argument helpKey="help_task_run_rule_ruleconfig" name="ruleConfig" type="string">
      <Prompt>label_rule_config</Prompt>
    </Argument>
    <Argument helpKey="Enter action to be taken" name="action" type="string">
      <Prompt>Action</Prompt>
    </Argument>
  </Inputs>
</Signature>

In the rule you can use the following code to check for action:

String actionStr=null;
if(config.containsKey("action"))
  actionStr=config.get("action");
}

then later you can check the value of actionStr
If nothing was entered the value will not be in config



Thursday, May 7, 2020

Making SailPoint TaskDefinition settings survive a deployment

There is some discussion (maybe not disagreement) regarding which SailPoint object types to put into the Source Code Repository and managed via SSB.  I won't get into all of them right here, but one of the most difficult decisions is around TaskDefinition objects.

The newest Object Exporter tool ExportXML.class does have a setting called "Strip environment-specific metadata" which removes the transient values of:

TaskDefinition.runLengthAverage
TaskDefinition.runLengthTotal
TaskDefinition.runs

from the XML it generates for TaskDefinition objects.  For many of us dealing with Tasks, there are some settings that we would like to manage in the UI and not be overwritten by a deployment.  I suggest that the following changes to the TaskDefinition XML files can help with Task Management.

The following settings may or may not be in this class of "preserve with deploy"
  •  resultAction (shown as Previous Result Action)
  • TaskSchedule.host (shown as Host)
  • taskCompletionEmailNotify (shown as Email Notification as a dropdown)
  • taskCompletionEmailRecipients (dropdown shown when above is set)
  • taskCompletionEmailTemplate (shown when above is set)
  • optional - Owner (not shown - defined on creation and only edited in debug
 How to do this:  Follow this process:

Take a current export - using the Export Tool or use my KCSExportXML tool (available soon)

Make the following edits:
On the  DOCTYPE tag (line 2) change TaskDefinition to sailpoint
Add 2 lines between the DOCTYPE tag and the TaskDefinition tag:
<sailpoint>
  <ImportAction name="merge">
Then indent everything below that down 4 spaces for proper XML indented format
Then at the end add:
  </ImportAction>
</sailpoint>

Finally, delete the XML attributes or elements you do not want overwritten on a deployment, my list is above but yours may be different.  You might include lists on sequential tasks, or on tasks with lists of Applications, etc.

Message me for help.