- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2021 01:54 AM
Hello Folks,
I'm new to service now. I'm trying to create a flow where the trigger is from an alert.
In the additional information of the alert, there is a key/value pair that I want to store as a variable and then use in an Action.
Additional info JSON:
{
name: "ashutosh",
id: "1234"
}
I want to extract the id and store it in a variable. Then, use that variable in an API call (action). If someone can provide me detailed steps as I'm very new to this platform would be nice.
Solved! Go to Solution.
- Labels:
-
flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2021 06:07 AM
Here is how I achieved it:
- In the sub-flow added an input variable and label as id of type string.
- In the action of rest API, I also created input variable and named it the same as the above.
- From the flow designer, there was an option to add a script, the key was very hard for me to find. I have highlighted the green box.
- After press that button, we need to add the below javascript code provided by
@Ankur Bawiskar . But we had to get to our records which were hard to find in the first line. Note: if you are trying to parse some other variable than additional_info, change it accordingly. Try to use auto-completion.
var str = fd_data.trigger.current.additional_info; var obj = JSON.parse(str); var id = obj.id; return id;​
- Finally test the flow. It works like a charm.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2021 05:33 AM
Hi,
Glad to know that you followed the approach I shared.
So you can use output of the sub-flow in the REST Step
please share screenshots of the sub-flow and the REST step used in main flow
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2021 05:56 AM
I was able to create input in the rest API action and use that from the flow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2021 06:07 AM
Here is how I achieved it:
- In the sub-flow added an input variable and label as id of type string.
- In the action of rest API, I also created input variable and named it the same as the above.
- From the flow designer, there was an option to add a script, the key was very hard for me to find. I have highlighted the green box.
- After press that button, we need to add the below javascript code provided by
@Ankur Bawiskar . But we had to get to our records which were hard to find in the first line. Note: if you are trying to parse some other variable than additional_info, change it accordingly. Try to use auto-completion.
var str = fd_data.trigger.current.additional_info; var obj = JSON.parse(str); var id = obj.id; return id;​
- Finally test the flow. It works like a charm.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2021 06:31 AM
Did you mistakenly marked your own response as correct?
Would you mind the response which helped/guided you in right direction as correct so that member gets credit and recognition.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2021 02:14 AM
var str = fd_data.trigger.current.additional_info;
A newbie like me would have completely missed it or could have never got it done. I saw this on another forum which helped me get the variable.
What we can do is, you can copy my detailed answer, I will mark that as complete this way you get your credit for helping me and other users get the exact answer. 🙂
Let me know what you think about this.