How do I parse the ActivityOutput.errormessage from Delivered Orchestration Activity

Dmatasek
Giga Contributor

Using delivered powershell activities for the first time.  Writing script to add a user to a group and testing possible error conditions.  Test case is trying to add a user to a group that they are already a member of.  Activity is throwing an error (expected).  But I am trying to find a way to parse the error message returned (which I believe is in ActivityOutput.errormessage) to direct the processing of the workflow.

Thanks

4 REPLIES 4

Bharath40
Giga Guru

Hi Dan,



If you are you are using Try catch statements , you can mention in Catch   as



Write-Output "User is already a member of group $($userattribute /change as per your req) to $($groupattribute/change as per your req)"


In sensor script check if(activity.output.indexOf("User is already")


send activity.result   as Failure . Pass this in workflow scratchpad results


Robert Beeman
Kilo Sage

Hi Dan,



I'm assuming that you are referring to the sensor script? Any PoSh error is returned to a variable called error:


find_real_file.png


http://wiki.servicenow.com/index.php?title=Orchestration_PowerShell_Activities#gsc.tab=0



You could do a simple sensor script something like this:


if(error != ''){


  workflow.scratchpad.errorText = error;


}



And then do workflow conditions or task work notes or whatever off of it.


No.   I am talking about how do I handle and Parse the error message returned from one of the NEW delivered workflow activities.   Specifically Add User to Group (Active Directory).


Hi Dan,



Sorry, I didn't realize that you were working with the Active Directory Workflow Activities. You should be able to drag the errorMessage output from the Data tab onto the input field of a later activity. If you need to actually parse it then you could use it as an Activity Input for a Custom Run Script Activity.



find_real_file.png