How do I parse the ActivityOutput.errormessage from Delivered Orchestration Activity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2017 06:52 PM
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
- Labels:
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2017 07:28 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2017 10:50 PM
Hi Dan,
I'm assuming that you are referring to the sensor script? Any PoSh error is returned to a variable called error:
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2017 02:54 PM
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2017 03:41 PM
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.