How To - Use the integrationHub JSON Parser - Paris Release
hi everyone this is patrick boschman i'm an architect in the it transformation practice i wanted to share with you a quick how-to video on using the integration hub json parser now available in the servicenow paris so before i get into the how-to demonstration i'd like to provide you a brief history lesson of how we got here so if you are a long-time servicenow user like myself you probably remember a json parser activity being available inside of workflow in orchestration then integration hub came around which is an amazing product i love and i use every day but for quite some time now it's lacked the ability to have an action that parses json rather than needing to script the parsing of a json payload and while this in no way limited your ability within the product it did make dealing with complex json payloads somewhat monotonous having to create the inputs in the outputs for a script activity every time you want to parse a json payload so now let's move into our servicenow paris instance and check out how to use the new json parser step as part of a integration hub action so the first thing you'll notice here is i have a rest step and it actually calls google's apis for youtube and pulls in a bunch of information about the various videos that we post on the it workflows youtube channels for your knowledge servicenow does have a integration hub spoke that can pull in all of the same information that this custom rest step can however it does require oauth authentication and i don't have that level of access within our google account therefore i rolled my own spoke with an api key being my method for authentication so let's go ahead and test this rest step and look at the json output that is returned when i query youtube with a video id so if we look at the steps we're going to notice the response body from youtube and we basically are returned a large json object this happens to be about a peppa pig video because that is pretty much all my kids watch on youtube so let me just copy this json object so i can show you how the parser parses the objects out of this json we'll go ahead and create a new json parser step here so you can see it from the top and we'll say the source data is the response body from my api call and if we hit generate target so if we take a look at the object that was parsed you'll notice that now all of the parts of the object are available to us you'll notice that these are now available to us as part of the data pill picker as well now the last thing that we need to do is just add an output so that this json object is available in a subflow or a workflow that you're calling this action from so if we go to edit outputs here you'll see that i made a new action output variable i call it video info and i assigned it the type object and if we exit edit mode here we can see that i simply made the value of that video info output object just my json parser step that top level json now let's take a look on how we actually consume this inside of a flow so to start dealing with this json what you need to do is you need to create a uh for each workflow logic so what you're going to do is you're going to go for each item in uh my video info which is the output of that rest action step and then you're going to use the array.object so in this case it's items so i'm going to iterate through my list of items inside of that json object and i'm going to update various records within this table that i have in servicenow so i'm going to take my field which happens to be i have a field in the form called title i am going to use items object snippet title to update that field now something i've noticed here when you use the update record option and you're iterating through this json you do need to create uh separate updates for every field that you want to update within the record rather than just adding an additional field here it seems to not work and i would guess that's something to do with the way that we're iterating for this json object so in closing i hope you found this video informative on using the json parser step inside of integration hub as part of our paris release please feel free to click like comment ask questions in the comment section i will attempt to answer them and if you have additional account type questions how do i get access to integration hub or how can i start using this within my servicenow environment please feel free to reach out to your servicenow account team thank you so much have a great day
https://www.youtube.com/watch?v=mVmOJNVDhCg