Getting an Email from a Person attribute
I have a form where the user selects an "affected account" which is a person attribute. Then, I have a workflow that needs to send a notification, and the notification body must include the email of the "affected account". However, the person field seems to only include display name. I've seen threads on here implying you can do a person API lookup to get the email from the display name, but there are two problems with that: 1. the display name might match multiple people's names and 2. the response from the API person search contains much more than just the email. If this were a script, I could easily parse out the response, but how can I do that in a workflow?
Is there any solution to my problem here?
Thanks for the help,
Answers (2)
To all who find this thread with a similar issue... I was able to parse the user's email out of the person type custom attribute in one API call using the Notify section of the response body.
Syntax for the "from workflow" parameter: Response.Notify[?(@.ItemRole=~/^(.*, )?Custom Attribute Name(, .*)?$/)].Value
Where Response is the name of value you're storing your GET ticket API call response in (defined in the workflow) and Custom Attribute Name is the full name of your custom attribute.
The workflow is as such:
1. Workflow step to call web method GET TDX TICKET, storing response as Response
2. Workflow step to call web method of your choice
3. In web method of your choice, use 'From Workflow' parameter Response.Notify[?(@.ItemRole=~/^(.*, )?Custom Attribute Name(, .*)?$/)].Value and with Name "EmailOfUser" (or name of your choice) and then using {{EmailOfUser}} in your web method somewhere.
See attached picture.
NOTE: The reason for using =~/^(.*, )?Custom Attribute Name(, .*)?$/ (regex substring match using wildcards) instead of a hard == (exact match) is because if the person selected in the custom attribute is the same as any of the other roles on the ticket (requestor, responsible, etc) their ItemRole name will be something like "Responsible, Requestor, Creator, Custom Attribute" rather than just "Custom Attribute". We also do not want to match "Custom Attribute Name 2" or "Test Custom Attribute Name"
Hello Tamara,
You would be better off just GETting the ticket itself, then refer to that response body to get the UID value from that custom attribute and do your user call from there to get their user account via UID and retrieve the email value from *that* call's response body.
Sincerely,
Mark Sayers
Sr Support Consultant, CS
Thank you for the quick response! Do you have some documentation or examples of working with the response body in a workflow? I'm very familiar with doing this in Powershell/Python, but it's unclear on how to use just one part of the larger response body within a TDX workflow. - Tamara Buch Mon 10/23/23 2:53 PM
I found this which seems like exactly what I need :) - Tamara Buch Mon 10/23/23 3:54 PM
Where 123456 is the attribute ID of your custom person attribute. Also, you might have to use something other than the "Value" property of that attribute's JSON response if that isn't the one that contains the UID of the selected person. - Mark Sayers Mon 10/23/23 4:48 PM
Below is how the attribute looks when returned by the GET ticket API call. As you can see.. no email ):
..."Attributes": [
{
"ID": 5308,
"Name": "UIUC-TechSvc-CSOC Affected Account",
"Order": 0,
"Description": "",
"SectionID": 0,
"SectionName": null,
"FieldType": "person",
"DataType": "String",
"Choices": [],
"IsRequired": false,
"IsUpdatable": true,
"Value": "8d407624-91c9-ea11-a81d-000d3a8ea9f7",
"ValueText": "Tamara Buch",
"ChoicesText": "",
"AssociatedItemIDs": [0]
},...
So is there another way to go about this through the Notify section? I tried to jimmy your syntax to match what I'm seeing but that didn't work either.
I tried: Response.Notify[?(@.ItemRole==UIUC-TechSvc-CSOC Affected Account)].Value - Tamara Buch Tue 10/24/23 11:08 AM
You're sure there's no way to parse out the Notify section of the response? That would make this a lot simpler! The API calls take quite awhile to run within the workflow. - Tamara Buch Tue 10/24/23 3:52 PM
Response.Notify[?(@.ItemRole=='UIUC-TechSvc-CSOC Affected Account')].Value
Now I can do it with just one API call! Yayyyy - Tamara Buch Tue 10/24/23 3:58 PM