Episode 24 - XML Parser in ServiceNow
hello everyone and welcome to do which doctors guide to users now episode number 24 today we are taking a look at something that is new in your place which is called XML porter and that is something you are using in the flow designer and integration hub and if I I never get this to work my name is Colin quick a Jewish doctor been around to service now for a couple of years now first as a customer then as a consultant in a partner and now I'm working in service now as a developer internally be around doing a lot of stuff everything from sitting in the service desk to being eyetooth process owner and developer and now I'm here doing videos for for you guys trying to let you learn how the service now is working on how to benefit from it as well a lot of community try to be here as much as possible helping out trying to solve and learn new stuff of course I don't know weh-weh for for everything so I learn new stuff every day as well keep on learning here yes about learning I wrote that book when I tried to peeling down the stuff that I wish that I knew when I started out at least here are a couple of bullet points what this boot contains of so a few interesting take a look at the Amazon your search for service now and you will have it pop up there as well but enough about me so today we're going to talk about the XML parser what's the reason for it what can we use for it how do we activate it there is a small bug right now that I want to show you how to get around how we're using it how we're building what we call the complex objects or the complete which I hopefully will do the next video about as well and of course there are some tiny limitations as well this is the first version would go through there as well so you don't slam your head against the wall for not understanding whites actually - how it does so let me skip my powerpoint let me try to get my monitors straight you see you are looking at the quads so let's go directly to the flow designer so basically this is when you're building for example old custom action if you might want to do an integration and what you get in return is an XML sheet and just to show you for those who's not that familiar I'm going to use this anyway so I'm just going to fetch some incidents to show you later on as well x46 excuse me there we go and if you look at my folder structure it's not that good that that's what not what we're going to talk about today so XML flow designer so he's going to show you a short what I'm building right now where we are actually creating WebEx meetings and you can see the different ways and this is actually in WebEx development or test instance so basically we throw away an XML and in return we get something really not too good-looking and here you can see is the XML parser right now as you can see this one isn't that big you might have an XML that is a lot bigger but still you would like to map these values that you get back to different fields and reuse it and stuff like that and that is where the XML parser will really shine so this is how it can look when it's done so let's go from scratch instead we just hit one of my test stuff it this one oh I forgot of course if you haven't done this you need to activate it sorry about that for now let's let's go back and show you and I'll talk about the bug as well I actually wrote down some notes I might look at them instead so I remember to tell you everything I know about this XML parser so of course you go to plugins he acts well and it's right here we just hit installed and it's been working as it should what I noticed and not only this one but even other things that is connected to flow that after install it suddenly when I get into the designer and let me just double check I'll just zoom in a little bit more like that suddenly nothing happens when you click on these after you activate it and I think it's a little user that actually actually the plane that will have this issue not sure but what you need to do to fix this and it's really easy is that you just go to screws background and I'll put in this line of code in the description down below this video in youtube and what you will do is just hit light cache manager dot and your seats run after you've done that you just open up flow design run again and then these buttons should actually work now normally and I don't go through how to build the rest up I'm just going to put it up here because I would like to have the rest steps out going stuff so I can show you where to put it so basically you have a rest at first you get the XML back and this is the place where you want to do now that's for to actually remove this one that's you never saw this one so this is basically how it does you have a couple of windows the first source data is okay where do the flow can takes a metal data in that case it's the response body so you can either drag and drop or you can just pinpoint it like that so this is where it gets the data then you have a payload view down here and in this case this is where you want to put in your two demo data or where X I have an example of the XML file how does it look when I get it so in this case I actually already had it this is just the XML data of the two incidents that are downloaded earlier so I get all these information back and let's say I would like to map these to some other records later on so I would like to keep most of your data earlier you have to probably script these and go through the whole process manually but what you can do when you have pasted in an example and you can have raw edit mode or you can have structure instructor actually make you drill down in allies way here you can see I actually have two incidents or means that I have a an array of off object inside here as well so I would like to have both in cells and in this case which is kind of nice with a complex data object is that I can put them in one of those and then in my flow I can actually use the for example the for each one to loop through the date that I've get them back which is a new nice thing as well but I don't manually would like to build all this I can do it by hitting create object then I first perhaps you would like to have the incident and then inside the insert object I would like to have number for example and I would like to have a short description and so on I'm not going to do you can already now see that it's take time and then important number I need to go in sorry not that one exit edit mode and now I need to define the XPath where is the data for this field now a nice thing is that all these boxes if I click on those they actually copy the XPath to that element talking a stick out and paste in that path so that's a nice way of doing it another thing that is a lot nicer yes this one the generate target button if I click on that one smack and you can see now suddenly we have all the stuff that actually can finish the hill in a complex object one of the nice things that we actually have here is you can see that you have the new things you can have array of objects and so on so this object contains multiple object and so on which is a really really nice feature double check we have the source field we have the generator yet we have this way as well [Music] one thing you think out that I know for example had with the WebEx is that I sending a request get the backed response successfully pasted in the payload of you got all the fields but if I got an error from WebEx they actually had another field that doesn't another element that doesn't show up when he successfully and seen I didn't paste that one in here it didn't wasn't created in here as well so make sure that you manually perhaps add those few elements so you had all the information because of course that element that I was missing contain why it was a failure so I really needed that as well now Fred of course you can just go in here even if I click the electorial I can still manually add more stuff if I want now when we're done we can of course that use this in this case for example have two reasons and I want to loop them through what the action need to do is make an output and hopefully your customized without the mechanical stuff like that but in this case I'll just create an object and this is the output let me show you so we are all on the same page let me just steal something and you can see that this for example the trigger these are the outputs from this action of course I choose an action that doesn't have anything let me just click on something will do this action called update record you can see the tap update record actually has the record and the table as an output later on I'll just I need to find the record all you say update that one and then later on if you want to do more stuff with this record I can get it and just pull it down like if i buy some reason doesn't make sense but i would like to delete that record I can just see number two I can't drag and drop like that so this is the output meaning to be able to get my XML data to the flow so I can actually use it I need to create outputs and since this was a complex object we're creating here you can see the unload of it you probably would like to create the same thing here so let's go and start from scratch I was thinking there we go and I just told it it's mellow yeah we would like to have that better now as you think and I would go through this more in the video about the complexity but to be able to have this to work I need to have the same structure variable names and so on in this object as I have in the payload object that I would like to copy in here so what you can actually do you can of course manually go through all of those but similar where you actually copied this data over here but the electorate you can actually go to the top one and he save as template now remember at the sailors template I actually looked at the structure how it is now I'll just save it as so it's safe now I can go to the output say that this one should actually start from a template Tandi R you can see it's created all of these for me as well directly now what can be a mess is that if I wasn't finished with my XML partial step and I go back here and now add something now that fields won't be added to the output so make sure you create this and are done with it one before you save it as a template and then when you go back here and create it you didn't get all the fields you wanted hopefully later on it will dynamically get all the fields and stuff like that but now at least in it doesn't really do that for you but it's still a really nice step so now when we got these we could actually later on go in the flow and run to a for each loop on those incident that I get back so let's see we have got two the fields we have the payload we have the manually with the XPath we have so now we're looking at the limitations and this is for then your plea so if you're watching this video later on and Orlando might be live these limitations might not be up to date any more but for New York it is so one of the limitation is that when you paste into this field the Dominator here is a limitation of 64,000 characters so if you have a bigger one you have to trim it down to make it work I haven't actually tested it but I'll probably guess it will be truncated and you will be trouble because you won't get all the fields I guess you do to do good to know as well us when we are and this is only for this field when you're building it so it's in the design phase we should call it it's not that limitation when you run it yes you know that another limitation is when this flow action has been run is that the incoming XML response that you're getting the max eyes right now is 10 megabytes so you know that as well another thing as well is that you might have more advanced xml's will have multiple namespaces right now the XML parser can't really handle multiple name places so that means that it will actually the namespace and put it into the different the same namespace and I guess if you know what I'm talking about do you know what I mean if you don't know what I'm talking about don't bother right now but what it means is and I'm just going to show you that you can have one filled with the namespace like that and then you can have the same element name but in a different name space unless you do like that so this work because here you can see in total its unique but we can't handle multiple right now so since we remove the namespaces you can see that suddenly these two elements has the same name so they will conflict so be aware of that if you're running into issues as well that thing is as well is that in XML you can have dots and - in the night spaces and that is not supported in the New York police either so that I think is about it let's make a quick summary I guess XML parser new in New York you activate as a plugin if you acted as a plug-in and you can't click nothing happens when you click on these for example then you need to run the code that is in the description of this YouTube video it's just a one-liner I showed in the beginning of this video as well and then it will work just restart the flow design then you get the XML parser step you have the source states that will define where is the income XML the payload view this one is basically just changing how you look at this table video and structure is something confused after you paste in your demo data so you have an example of the response politic you paste it in in royal edit mode and then you can see you structure it might be a little easier to go through what feels and stuff you actually get you can either manually create the toilet or you can click on generate target to actually create it after that then we have something here if you do you manually you can actually define the different fields and flex paths you actually find the field and then just click on it to copy a path and then you just paste it in there as well remember that in the XML demo that you might have gotten it not contains doesn't contain all the fields that they actually get depending on the scenario so you might want to add a few fields manually for example or you just paste in a new demo data and just copy over that path for that one for example when you're done you might want to save this as a template right now because you want to take the same object and have that as an output just click an arrow down oh sorry you need to be on the right spot so you need to be in our always say that that's why I think here we go you need to be on the top one and in edit mode then you can click save as template and reduce this later on when you go to output and you create the object here let me scroll up and I'll just do like that choose create output I'll just write something and then I choose object and then you should start from template and you select which template you want to use remember that when you hit save as template and if you do changes to T's target it won't be reflected in the template and that's why even the outfits so make sure you build target finished and then make the template and move it over limitations when you have terminator 64,000 characters incoming XML payload 10 megabytes the XML parser can't handle the named multiple namespaces it can't handle dot or hyphens either and I think this is about it so thanks for watching and hopefully I will get the video with the complex data a bit sooner than between this one and old video so see you around and thank you for watching
https://www.youtube.com/watch?v=18DnY4FfMqI