
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 03-31-2021 07:40 PM
Let's continue the integration journey building upon the lesson in my previous article introducing integration to the non-technical.
First: Wikipedia can answer "why is integration important?"
Also an anecdote,
Quick recap to my prior article: I demonstrated that many data tools are omnipresent in the business world but we don't think about them that much. If you ever synced your contacts with LinkedIn, or SurveyMonkey, or uploaded your bank records into Quickbooks, what about TurboTax that recognizes your tax forms, reads the numbers in the boxes, and files your taxes. In the TurboTax example there are probably dozens of integrations happening behind the scenes and that's how a lot of Apps are built nowadays. You and I are just going to do small integrations but that's what these Apps are made up of, a lot of small integrations.
So let's try to move forward with confidence, these tools are all man-made, someone built them and you can work with them too. There's a lot of buzz about digital transformation, if we can properly demonstrate the basics of integration, we can express the concepts and vision we want to achieve to the engineers who are extremely well versed in these tools, and then we can see these ideas come to fruition. Rant over.
Remember this little guy?
Have you ever uploaded data to the web from a CSV/Excel with only one record in it? Probably not, unless you missed a contact, and needed to sneak them into a greater list. We need to learn how to load multiple rows of data into ServiceNow.
Now let's take a little walk down memory lane. Remember back in the day when you took that programming class on Udemy.com and learned all about Floats, Strings, Numbers, Binary, Objects, Arrays, DateTime format until ... well maybe you got really drowsy, or you hit fast forward, or you did the exercises but thought to yourself "when am I, the next Bill Jobs, - the next Stephanie Gates, ever going to use this stuff?" - you scoffed as you dreamed of the next killer app and then dozed off when formatting UTC dates. Get ready because you are about to get a ROI on that $11.99 Udemy class. P.S. I love U... demy -- SIKE!
We are going to learn about Arrays. Arrays are lists. End of lesson. You're welcome.
In all seriousness here's a list:
Now remember we are communicating with our REST API Trigger with JSON so let's see how to make a list (array) in JSON.
{
"array" : [ {
"assignment_group" : "5f6441efc0a8010e0177fcb589156352",
"description" : "major outage"
}
,
{
"assignment_group" : "5f6441efc0a8010e0177fcb589156352",
"description" : "minor interuption"
}
,
{
"assignment_group" : "5f6441efc0a8010e0177fcb589156352",
"description" : "Modem sounds?"
}
]
}
Do you see the differences from our last example? Feel free to copy the above sample and paste it into Postman - remember you'll need to use the assignment group sys_id that you used in the prior example from your own instance. You can use the same sys_id for each item in the list and change the text up a little if you choose.
Notice this pattern without the words { [ {},{},{} ] } - what does that look like to you? Three Ghosts in a graveyard? three tulips in a planter box? three coal miners in the elevator of a mine? three crabs in a crab trap?
See the pattern? it's a list, or an array, and it's designated with square brackets and a comma separated list.
Let's add the quotation marks and colons to finish off the pattern:
{"":[{"":"","":""},{"":"","":""},{"":"","":""}]}
Now scroll up and look at the sample code with the fields filled in. I know it may seem mundane but it's worth building the structure up this way in your mind to get used to JSON.
Ok now to working with Flow Designer and Integration Hub again. Remember, the computer is stupid and we are smart so we must tell it exactly what we we want to do. Now we are going to use the GUI in REST API Trigger to match the JSON that's coming from the outside world. So you'll need to use the Trash bin button and the Plus button to get the prior structure to match the new structure that we're going to consume in the endpoint.
Object, Array.Object, Object, String, String.
Next we have to build a custom Action. Back to the Oil analogy, We have a gusher of Oil here in the Rest API Trigger and we need to contain it, one doesn't just refine the oil right from the pump. So we need to contain it, and then process it.
Custom Action. Click on the Home Button in Flow Designer, Click on 'New', then 'Action'. You'll be asked to give it a name, application scope, etc... I found this creation step intuitive.
Now click on '(+)Create Input' and once again you'll build out that structure just like above: Object, Array.Object, Object, String, String.
Next on the Output outline on the left bar again we re-create the structure and drag and drop the input variable pill into the top level of the Output like so:
You've duplicated the structure in the Custom Action Input and Output and are telling the platform to move the body from input to output from the top level body of the object.
Save it, Publish it, go back to the flow designer.
Almost done.
Remember to delete the pre-existing Actions in your original flow - hit the (+) button to add your custom action. Then drag in the Request body from Trigger-REST API - Asynchronous
Now we hit (+) again add a flow logic - "For Each" and drag in the array from our custom action.
Now we are going to add an offshoot to that 'For Each', we'll see the second (+) sign open up underneath the 'For Each' - from there we can re-add the 'Create Record' for the Table incident, and drag in the assignment_group and description field from the 'For Each' section of the data pills.
And that's just about it! Save it, Activate it, be sure you have the right sys_id from your instance's incidents assignment group and go ahead and hit the Test button, try it from Postman, remember to paste the example JSON into the RAW section as I showed you above.
I think you can take this section from here! I am going to leave you to it, I showed you Postman in the original post, and how to send messages to your endpoint in a couple ways, and with the sample JSON I am confident that you can do this! (Feel free to post questions below... let's keep the conversation going!)
You've just loaded a list from an API endpoint. You've shown one-way integration into the ServiceNow platform. CONGRATULATIONS!
In the next episode we will demonstrate a Bi-Directional Sync - based on the work we did today, this will truly be an integration example when we are done!
Feeling Stronger?
- 1,013 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
The oil/data metaphor really sold it for me. Thanks for sharing your knowledge!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Excellent post!