Share all details about your problem, including any error messages you may have received.
I have a Run Rule Task calling “TEST ABC Rule”. In my rule is there any method I can get the name of the Task that is running the rule (i.e. TEST ABC)?
If i good understand you.
Yes, in SailPoint’s IdentityIQ, you can retrieve the name of the task that is executing a rule by accessing the context object within the rule. This context object contains details about the task, and you can extract the task name from it.
Quick example:
import sailpoint.object.Task;
import sailpoint.object.TaskDefinition;
import sailpoint.api.SailPointContext;
// Assuming you have access to the context object in your rule
SailPointContext context = (SailPointContext) args.get("context");
// Get the task object
Task task = context.getTask();
// Check if task is not null
if (task != null) {
String taskName = task.getName(); // This will give you the name of the task
System.out.println("The task running this rule is: " + taskName);
} else {
System.out.println("No task is currently running.");
}
There is no getTask() method in the SailPointContext. Also there is no Task object. You could access the task configuration using TaskDefinition object.
I am looking for a dynamic way to get the name of the Task running the rule is there any possibility on this? TaskDefinition taskDef = context.getObjectByName(TaskDefinition.class,"TEST ABC");
I still have to hardcode the Object name (i.e. “TEST ABC”).
Because we would want to add some conditional statements to our rule and depending on which conditional statement is true, the rule would be executed on different applications.
I don’t think you would be able to achieve this. You would need to create separate rules for each TaskDefinition.
FYI
There is way to pass the arguments to the Rule from TaskDefinition, but this is not the answer for your question as you still need to refer to the TaskDefinition by hard coding the name.