I believe this line is causing problems - I would suggest to remove temporarly whole signature as it’s not needed really. Try to remove it and chekc if it works
You dont need to have the taskResult as a variable. It will be on the context to be captured and updated.
Just remove the TaskResult from the input an try to add the massage.
The signature doesn’t really matter at all. It’s purely informational to let you know what is being passed into the Beanshell namespace. As @ipobeidi mentioned originally, the error indicates that the taskResult variable is of type String which doesn’t have a method for addMessage(String). This method is only applicable for a sailpoint.object.TaskResult object, in which case the taskResult variable passed into a Rule Runner task should be of that type, but it seems like you are not maybe running this rule properly via a Rule Runner task, or you are somehow re-declaring it as a String?
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule language="beanshell" name="Vishal User">
<Description>A rule to disable a user.</Description>
<Signature returnType="SailPointObject">
<Inputs>
<Argument name="log">
<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="taskResult">
<Description>
A sailpoint.object.TaskResult object that can be used to set messages and responses for the task result.
</Description>
</Argument>
</Inputs>
<Returns>
<Argument name="taskSuccess" type="string">
<Prompt>Task Result:</Prompt>
</Argument>
</Returns>
</Signature>
<Source>
import sailpoint.object.Identity;
import sailpoint.tools.Message;
import org.apache.log4j.Logger;
import sailpoint.api.ObjectUtil;
import sailpoint.api.PersistenceManager;
String name ="1234567";
if(name != null && !name.isEmpty()){
taskResult.addMessage(new Message(Message.Type.Info, "Identities updated",null));
}else{
taskResult.addMessage(new Message(Message.Type.Info, "No Identities",null));
}
return "Success";
</Source>
</Rule>
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE TaskDefinition PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<TaskDefinition name="Vishal User" resultAction="Rename" subType="task_item_type_generic" type="Generic">
<Attributes>
<Map>
<entry key="TaskDefinition.runLengthAverage" value="0"/>
<entry key="TaskDefinition.runLengthTotal" value="0"/>
<entry key="TaskDefinition.runs" value="0"/>
<entry key="TaskSchedule.host"/>
<entry key="ruleName" value="Vishal User"/>
<entry key="taskCompletionEmailNotify" value="Disabled"/>
<entry key="taskCompletionEmailRecipients"/>
<entry key="taskCompletionEmailTemplate" value="Task Status"/>
</Map>
</Attributes>
<Description>A task that can be used to run an arbitrary rule.</Description>
<Parent>
<Reference class="sailpoint.object.TaskDefinition" name="Run Rule"/>
</Parent>
</TaskDefinition>