Inside the Barrel - Merging and Exporting Records Across Instances
foreign hello and welcome to another exciting episode of inside the barrel where we talk all things Consulting for servicenow today is going to be like a hack of Friday because we're doing something fun on Friday I love fun fridays yeah I'm excited too because I think you know from our last episode when we got to write a little bit of code and then do some flow designer stuff it was yeah let's let's do something uh similar as well yes yeah yeah and this one is a fun one so today um we're gonna talk about migrating records XML records across instances um and for for those that don't know there's kind of two ways uh or there's there's a few different ways to do it but uh the the two main ones that come to mind are the the first one is just right clicking exporting as XML and then moving over um so that's kind of the the the easy way is just taking the data record and exporting and then importing as well the problem is if you have hundreds and hundreds of those like it would take you forever even if you just select a few of them on a table right click export and then move over um the other issue with that is you may lose some references so if if you're exporting something and you know you also need a related record as well um it's kind of really painful to to do those the other way is the update sets so there is an awesome utility out there around add to update set and that needs to be manually maintained in order to make sure all the relationships are there so those are kind of like the the two main ones there's a few other unique ways to to do it but uh recently we saw someone from the community post about um how you could do it manually so let me kind of bring up that uh that uh that article or that message and we'll kind of talk about it so so shout out to to Mike uh in the community uh he if you don't follow Mike um he does and his name's in this user display value right there um he does a kind of like excerpts um once a week I would say or every couple days about just creative things that he he finds um they could be anything from like the Json view adding it's just very simple things and this one was talking about merging um XML files together and essentially what you know his strategy is if you have to export a bunch of Records you can right click export an XML uh and then you can then um add other xmls into it so you can see from this image um that he he copied from other XML files sound sounds cool uh problem is is that's very manual and we don't like manual laughs I I don't know if I've mentioned it before but like the first and only programming book I ever bought like the first page said programmers are inherently lazy because you know we like to build things to make our lives easier right yeah manual no good um and uh and so yeah I thought we would you know take a stab at seeing if we could automate merging essentially um XML files and we'll go down the rabbit hole of exploring what apis that servicenow provides and maybe their pitfalls and see if this is even possible um because because I commented on uh his post on LinkedIn and I was like someone should build a tool and he's like go for it I was like oh my dear so we'll see how I'm a little accepted I'm a little rusty though so we'll see how far we get um yeah and yeah you know speaking of Json I think I I um like to post on LinkedIn yesterday about this one this new thing called uh it's what is it HT https whatever Jason crack Json crack should I bring it up should I show yeah bring it up it's pretty cool like it's it's I usually use um Jason lint to to look over my Json files but this one this one's nice and pretty look at that oh so you write the Json and then it even kinda shows you the relationship between yeah yeah that is that is really cool all right well unfortunately we're going to be dealing with XML today where's our XML crack yeah let me let me try typing XML crack and see no yeah unfortunately not there um but it's super cool yeah shout out to the creators of this it looks like it's open source right I see a GitHub little icon there so um yep open source so super super cool um all right so kind of let's let's kind of get started um the first thing I would normally do when thinking of let's you know play with XML is what does servicenow provide for us um and so what I found is a little bit of documentation documentation on this XML document too I know that it works in scoped or Global so great great way to start there uh maybe maybe we should do this in a scoped app and get all the es12 goodness you know I was going to ask you about that because I when we were talking about it earlier I was like oh man I wonder if there's gonna if our lives will be made easier if we throw in a scoped up and and we're able to use the newer yeah JavaScript Let's Do It um so I'll do that as we as we kind of go if I have and then screens the other thing I was noticing so they call this one XML document two that means there's an XML document one so I I just want to shout out that look you know naming stuff is always a problem for developers like I can spend way too much time coming up with names but when you see like a Enterprise level company doing one and twos um I don't think it's so bad if I do one and twos especially when you start seeing gr1 gr2 you know come on yeah yeah I wonder if there was a one or like maybe they're following a standard that XML has like there could be uh maybe it could be that they were following something else so just a quick recap I just created a scope which you guys all saw and I switched to es12 so we can use all the the funness uh in this um cool and so kind of so again kind of what we're trying to do is create an XML that looks like this um and so what I have is two files so here's an example of it looks almost identical where there's an unload and and then you have this you know records underneath it so in this case I have an incident right it just looks like a basic incident and it has also a um a work note related to it so a CIS journal entry and so that's what's nice is if I import this XML it will import all of these records into the instance and these records live on different tables so so that's good I have another example of another one that is just an incident and so what we're trying to do is get this guy inside of here as another as another line item so so looking at uh this XML document too um it looks like there's a create element so this adds a node right so we can like you know do some sort of test one two there's some attributes as well and then you can create an element which a new two see so this this looks like it would work for us right because if this is the unload right this is the the thing we need underneath it and it just adds it to the bottom right now it ideally looks good the problem is is can we just pass in an entire other XML string right or do you have to add that node and then fill it out yeah I'm sorry add that note and then add all the subsequent nodes after like is is it manual to where you would have to do each the parent node and then all the cascading nodes below it yeah that's that's the scary part right is like I wish there was like create like new like I don't know node we'll see so maybe this one isn't the one we need right now but this one says create an element with text values so we're getting closer so in that case you're passing new and test which looks like now we have new and it has the value of test so this looks a little bit better um but it's still not but one thing that's also that we we haven't seen yet is what happens if you have like an attribute right like this doesn't this doesn't show us you know how to add an attribute so like like this is essentially one that has an attribute but right I just can I do like new and then equals or something you know like so so we could so let's let's I mean let's kind of play around with that right so um what a a quickly show is Visual Studio code for a second and let's do a new share on the screen oh um I don't actually know how that's okay what I was going to show is on Visual Studio code there is a join lines uh functionality yeah let me let me let me show it let me yeah I'd like to see this I think this is a good one to show at um I don't even I don't even know how to stop to share I think you've stopped like I don't see it so you'd have to just change yeah my screen right but your single screen yeah but maybe I can't I broke it how about John bring up visual studio all right I'll bring it up I'll get it so funny okay and we're just doing a new file is that all we need yeah and we're gonna take some XML with it and oh do you want an XML file then yeah yeah show an XML file we find it should be relatively simple the data isn't important you can even just write it out just write you know some sort of node which is an XML and then a closed one let me see if I got the right oh nope that's the wrong that is an old what is that that's an old version of this oh man all right there we go open Okay um so let me share window there we go okay so I'm gonna throw this on the screen so uh great um so one issue you may find is if you try to copy and paste this into the like background scripts like sfar let's say you wanted to create a VAR and do this it would it would like give you an error right like sure multi-lined um oh we lost we lost John well it would give you an error it'd be multi-lined a multi-line issue and um I can't I can't resize my screens without them reloading Oh weird yeah it is weird I don't think that's normal yeah I figured I figured it out John so oh did you okay my screen so here's an example of you know an XML file if and what I'll try doing is copying this right and we're gonna have to do a few different shares to kind of share this um and then we go to this screen and I wish I could have like multiple shares ready and we go to like background scripts and varfu equals you know like that or actually let me do the single quotes since XML has double like it'll it'll yell at you right like not not possible so yeah um one fun thing to know about Visual Studio code is back to it oh I can't show multiple screens oh nice oh yeah there we go now we're now we're cooking so if you go to the command palette there is join lines oh nice bam so now it's all in one oh so it's it's the return carry or the return the new line or whatever's in whatever is getting put in there between each thing yeah that it does not like okay so there we go so you can kind of just like quickly join an XML to make it into like a string if you needed to so um okay so so now let's kind of go through so let's I mean let's now that we have this let me name it XML string as well so that we can just do some you know copy and paste so no string look at that and let's let's run this um and we're in our new scope we're oh but this is going to run in global lineup actually Let me refresh this page yeah there we go so now we're running it in our scope um so yeah so essentially what this should do is add new and test at the the end right so if we go to the bottom it should have added new intest at the end new all right okay it's at the top interesting that's okay because I was just looking at that does that actually say that it adds it to the end uh it should add it at the current state of where the note is to yeah it creates and adds an element node with the text child node to the current node and I think it's because there is a function in here let me go to where this is there's a function to set current element right so there is ways to like to do that um but that's okay at the top is fine it's not a big deal but the question is is can we do like some attribute here like if we wanted to do this action insert and stay right like is that gonna oh geez is that is this gonna actually work right like hey look at that and so it does cool so well actually you're missing the clothes on that like the new doesn't have a closing yeah this is like weird right like added it a few times yeah that is let me just run it again yeah uh super interesting so oh it adds oh you know why because I think there's a parser in there that says okay the first word or uh yeah the first word is how they create the closing tag and because you put something to the end of it it just came apart and was like I don't know what to do about this yeah so so so even there right like adding like attributes as well it isn't clear in this documentation you know so moving along like it looks like we can get document elements right so so that looks useful but like again it's it looks like it strips it's stripped stuff right so not super useful get the first node so even if we wanted to get something it returned some some data but again what we're really after is the whole line um getting the next again also looks good um so this is the only one so get node so we can we can get the node um which looks like it's good but there's a note here that's not good for large documents so now it's scary but it did actually return the node which is which is good right so like this is something more that we're after but that's only if we need to to get a node parse XML um so this is like if you wanted to create the document you can create the new document and pass parse XML on a string or you could just add the string up top so not super useful for us setting the element is like to where we want the current route to be added and then you know making it a two string so uh Dimitar there is saying that uh he thought there might be a set attribute method available but I I was just looking to see if I could see that all right um maybe on XML node so on XML node there's a get attribute and the node iterator also so yeah it's it's kind of weird it's like I feel like yeah most of this was made to like do some cool stuff with but it feels like it's not meant for merging and that's kind of what we're trying to you know merge to xmls together at a root node right so hopefully servicenows watch well I doubt they're gonna you know add a function text now but it would be nice um so yeah so that's kind of like our first blocker here is like how do we get without doing lots of iteration right like because we could even if we could Loop through all of this like totally make sense but if we can't keep the actual node um then like or keep the the entire thing then we're going to run into issues and if servicenow is saying you're going to run into performance issues on on get node then like we need another solution okay is there anything outside of like is there anything built into JavaScript that would give us the abilities to build so that's a good question XML so there's a they have another function here called XML helper um for parsing XML and you can make it two objects so it turns it into a JavaScript object so we could play around with this to see let's like what like the the issue that I already see right now is like we still lose some some attributes here we're we're potentially going to lose some attributes but Let's uh let's play around with this so so in this case instead of uh instead of creating the document it wants us to create use this helper function [Music] so I'm going to comment this out and run this XML helper so my guess is this can't be used inside of this scope yeah illegal access okay so that's super lame but let's go out there let's go outside of our scope for a second just to run it yeah so so it looks a little bit different right so now like if we're looking at at this the unload unload date so it it has like it has the data or that information in it the incident it has the incident and its action so this looks like we could potentially do something with this except now we're just like looping through a massive thing in order to to get all of it and then rebuild it so then I wonder at risk if we're gonna do it wrong yeah I wonder if that object object is the attribute like it it gets caught up on I don't know it's hard to it's hard to say because you have that action inserter update any and well no I guess it's there I wonder why it does that with the object object yeah I mean what we could potentially just try doing is um like log this GS dot info Json Dot uh stringify uh try let's try that all right so this is what that object looks like so we have the unload date we have an incident with an action so it looks like this at sign is saying it's an attribute right and then the incident this is the attribute and then you know it looks like all of the the XML properties so so it looks like in theory we could do something with this XML helper one thing yeah it's only in in global which is a pain in the butt um um but it does look like if you did form a Json object we could make it into back to an XML dock so uh should we go that route what do you think in or should we like say hey we have the two things just take this whole thing and move it on the next line of this right like what what do we well but I'm not sure that without you you know it seems like we we'd have to like if we want to use XML helper we're going to have to create um we're going to have to know where we need to put it and I think though that may not be as a needed thing is like we need like we could just say let's find the last you know we have to make sure we're in the right um the right node within whatever node right like is it the same level as incident that we would be merging this into or is it so I wonder if what we can do here I'm just going to copy so this is XML string our XML stream 2 and she loved those so here's here essentially are my the two of them right so we have uh I'm just gonna copy this because really I think I think we could do it as as part of the string you know once it's been stringified and then once we get it in there as you know a properly formatted string then once it's parsed back it should be correct right am I thinking that right yeah I guess my question is um if I think oh I think I copied the wrong oh those are two separate ones that's okay like my question is is maybe can we just add it to this Json object yeah that's that's what I'm saying because you've stringified it it's now just a string and as long as we add it somewhere in that string properly format it as another string you should be able to parse it back right I think my question is is yeah like if we just pop it into it so let's not even stringify it right like we have oh I see I see two objects right um and now we're gonna because we're in global merge two objects JavaScript oh my God this is gonna be oh yeah if we had the spread operator we'd be done sweet um yeah so not gonna be able to do that um but yeah I think that would that would essentially work so yeah maybe object out of sign which I think is going to get us in trouble but uh yeah object there are some methods there that it doesn't give us but and I think it takes the first one yeah objectives oh it's because I have typos [Applause] yeah so it doesn't look like it well if it did add it maybe I these are two different objects right yeah do you need to do a copy of it well no they're two different uh maybe um yeah I don't know it's like add one object to another JavaScript now I think the old yeah I think the old-fashioned way is um I was just looking through vanilla JavaScript let me send you a let me send you what I found on that one because you you can do it you just have to Loop through it and do it that way okay kind of uh kind of a you know obviously the old-fashioned yeah let's let's look at that welcome to life when we have some limitations but maybe yeah so it looks like looped through it create a new object Loop through it uh interesting oh you know if you scroll further down there's a method that does take into account the object object to it's about it's almost all the way down extending is what we want right here so it does give you it gives you a function that you can but this looks nice right like yeah yeah extend this is where we we just trust the internet and you see all these memes about pulling code from GitHub I mean from stack overflow that wouldn't lie to us that they want us to to to use useful things and you know I I saw something yesterday from programming program programming humor where some someone posted something saying you know when I can't write code I don't get on Reddit and ask for help on it what I do is I purposely write the code badly and post the code because it looks like people won't people won't help on Reddit but they're more than willing to call you out on what you did wrong beautiful beautiful merge uh two Okay so if the internet or if the internet likes us object one is oh the internet like just object okay hey [Music] maybe that did work wait no because it doesn't seem long enough does it yeah because we have this is one unload and then we have this unload right so it doesn't look like it's it's working maybe let's add True to this because I think that was this is deep merge deep we only see one on load because ideally we'd see two things in here right we would see like both objects but we just see object one so didn't work John my Google sleuthing is leaving me helpless here yeah it's like because ideally I mean it is an object like maybe we can convert it to I think I think this is yeah I would just do it to a string convert it to a string and then concatenate it at the right point terrible [Music] that's why we call it hack a Friday yeah this one is like you know looping through it if it has it but will that that won't necessarily merge that seems like it will like override yeah it'll just combine it I'm not sure that's what we want um yeah it's like because ideally like it it had like notice how it has like this comma here and then it just does another one like that's that's what we need so it's like we just need to add it the object to it so and I wonder if so Dimitar oh yeah well I didn't mean to cut yeah but Dimitar says that set attribute works and he's chained it to create element okay so we can so we can Loop through uh we can we can Loop through it so well so let's let's go back we'll take a pause on this for a second we'll go back to that set elements is he's found hacks are these undocumented because I didn't see it in the the documentation so so create element with text let's say new test and then chain it set it oh I guess and then so we set the attribute to be attribute Direction action yeah insert and update so oh yeah yeah okay so we could Loop through the entire second one right so we could Loop through this one because I think we could do something like um like we can get the document element of the second one so where is that function yeah document element so we could do something like this so we'll take a pause on this for a second so we're gonna do doc two dot two dot two two okay so let's see what that returns so it returns everything because we're getting the get contacts but if we get node value Maybe or maybe root node cool so yeah so it gets the whole thing so that is looking promising problem is is we don't want this unload can you if it's an object you should be able to you should be able to delete an uh it out right oh yeah I guess first child would be that let's see no no because that's a child it would be the root not yeah I was hoping that we could just kind of get that let's see what if what the node iterator looks like and then like next no I was hoping that this Guild document element would just work but so I was I was looking at um this I'll send it to you on on uh stack overflow oh yeah and uh so you can yeah there's some there are some things in there because you can it looks like you could serialize the XML oh man so like my my thinking here John is just like if this is a string like just fine concatenate it find the element and just add it to the string and then make it an object well we could do that too I mean there are there are tools so much easier [Laughter] yeah wow Returns the root note of the documentary so the other thing is if I don't know maybe I messed up like um like because the issue is is like it removes this part like if if this wasn't here right then I run this it would be correct oh no I guess it isn't still yeah weird um yeah it says unload that we're trying to get rid of where's your are you missing a closing like that XML that's a single line it doesn't have a closer on it right correct yeah correct okay all right yeah um yeah so my thinking is like we could just manipulate the string and like remove the unload at the end add all of our other stuff and then just add the unload when we're done yeah right why not because I think of this it's like remove the unload add all you want and then just add the unload back in sure so now we're just doing string manipulation instead [Music] [Laughter] which I don't know if that's better or worse and I don't know if Dimitar is gonna like us or not [Laughter] um but yeah so like let's see like so so let's kinda comment these out for a bit so the first thing we can do is take like our first string dot replace all uh-oh Dimitar is gonna try to beat you yeah yeah hopefully he does laughs um with this uh and I think oh but you're in you're in global though I think but someone was telling me that service now actually created this function so did they oh okay so if I look here it shouldn't have unload or it doesn't yeah let's go back to our scope and I did unload unload oh so maybe this actually I need to set this to a variable VAR through because it doesn't actually it creates a new one yeah so look we got it there we go yeah I think that works in global as well yeah so servicenow created its own okay as well all right but now that we don't have this we then need to like regex right everything after this unload right so let's go to our reg xer friend regexer now the problem here is if you're if you're doing this you can't just hard code that string you you have to do way more regexing and say really what you're what you want is between uh yeah I get what you mean the alligator question mark XML and then the what's what's the uh oh that's gonna be so difficult trying to think of how you would you got you got big brain this will work you got this John well the the big problem is um so we know we need this right so easy yeah and that would always be the same but it's your closer because you don't know if it's always going to be an incident you know what I mean yeah like it could be it could be something else so I think we just need everything after the like one two well what you would need is a times like you could do a time stamp you could do because I think you're probably okay with uh at least two of those numbers right so the 13 double quotes uh closing angle bracket oh yeah so you're saying like the what's the digit d d right uh well you may want to do colon d d but it's not even picking up there we go okay so we found our yeah and so the first part would be just like you know the angle bracket question mark XML because I think you could say everything in between that get rid of because I think I want just everything after this is there a regex for I feel like regex after this and we're done right oh regex uh that's all we need after yeah it's just like we found the first match and then we just need everything after it uh okay so match after foreign match maybe the Plus uh the plug I thought plus just was uh oh so it's you could do a you could do capture groups right so if you match to the end of that one the second mat the second group right so everything after that should be the group two is that right I'm just trying to think if they're what the after is yeah I was hoping that it is oh yeah you would have to do uh so after that first part you would have to do kind of you know capture everything afterwards so um probably with the um what are they called what's the thing on the shift eight um I think this is it a star yeah because we got capture group one yep and then capture group two yeah and obviously obviously you could fine tune that because you know I I think it's a little open and what's the what's the regex I feel like there's a Zone function here right or maybe this is well I thought it was a an array I thought it came in with an array oh that's just replace um oh I guess we could replace uh uh capture group one yeah so uh replace all method I guess 12. where's our handy dandy example one I don't want these blogs did you not favorite it it was a different a different time John uh but how do you say but you want to make sure you're on the specific capture they made this one but we're like we could just do this okay I think we could just oh you're right though you need that specific capture okay so what's yeah regex servicenow there we go service now we'll just give us an answer oh what a beautiful what what is this oh there we go okay so raise your Expressions give me an example okay this looks great uh let's do this so and then we just need our amazing thing that we did apparently I can't copy correctly the Dimitar be me uh not yet I haven't I haven't seen anything yet I think you don't do this you know quotes though I think you do slashes forward slashes oh on this no I think the single quotes here right um maybe I thought it was just slashes whatever that's fine we'll see okay um well I think we can like test if this is working right so we pass the string then we do the replace all and apparently they're replaceable oh here's how you do it in normal JavaScript interesting Okay so let's try the normal JavaScript one and we're going to pass in XML string and we're replacing I know but we want to get the second group so before we do that let's gs.infootu I'm I thought it was yeah but oh after what's the isn't it a match I think you have to do a match right yeah yeah so it would be it would be like if you go back to your script I think it's uh you just do a DOT match um with the string so it would be food 2.match and then uh whatever your uh XML string is true and you probably need to set that to a variable too yeah yeah [Music] uh did I oh that's good let's do that for a second cannot find match in object saying it doesn't have a match in our thank you oh I think I think this is not the way there's I don't think this is the syntax match this now try it with just do slashes instead of single quotes okay this yeah I think it's just a like a syntax issue that I mean that's how they're oh so uh yeah slash with the G after it so there's no yeah there's no con yeah wow oh wait that's that's on the string so I think it's different because like oh oh yeah um so futu uh wait so XML string yes um yeah so you don't even need this or you could yeah I think that works okay so then I think what we can do is like zero right and then one okay so the the match didn't like us right like I thought like after the match you could you know access it right yeah I thought I thought it came back with a uh I thought it was an array for your groups I thoughts help stop the madness oh this article is so long wow this is like so old oh this one's from two years ago it's just wow as you can see we do not use regex's very often I I don't use it as much as I used to yeah I mean that was a nice cheat sheet and all but I just want to know maybe I'm not asking the right question uh matches Rejects eight years ago we're going down rabbit holes here um server side script using match project servicenow let's see okay so this person is using replace I'll see I'm getting I'm getting when I look at it I get a loop a four each Loop here let's what does this guy say this guy says we have our string so XML string dot match and it looks like we have that and then you can console log it it's what we're doing well maybe stringify it and see what it looks like maybe doesn't like this yeah I don't I can't imagine this as being a like a I didn't think it would be an object let's see you should have well I mean so I get the colon 55 right like yeah that's oh that's the first match because that's part of but but it doesn't break it into a second yeah this this grouping isn't isn't working oh take off yeah take off that um um no maybe not oh well I guess you could do so if you um is there if you scroll down what does it give you a capture group too no okay so do this up there um put so this does oh that does give you a capture group too but I don't know if that's correct right so Oh see it's giving you the same response yeah so there's a group point and then group two is correct this is what we want right so match zero but we want the groups and the group so we want this No it should be zero maybe zero and one right so yeah but but it doesn't so maybe there's something about wait go back to your code does that yeah oh no you have it okay I just didn't see it do square brackets make a difference like if you put each um no put put the put the round parens back in um yeah and then put each section in a square bracket interesting um uh no I guess not does this not generate code for you uh I it may actually generate code um but yeah I think I think there's something like access group it's like you can use matching groups okay Clyde filter oh geez this is not exactly filtered out match hmm I Blame You John yeah probably about right um I could we could oh put the can you put the whole put the whole thing into well I don't know maybe not oh that's using exec I mean who still does that anymore yeah I wouldn't want to use uh I don't think it'll let you use it so that's so weird that like it does capture it correctly but it doesn't look like it's two different groups right so maybe service now doesn't support groups yeah but that should be a JavaScript reject this thing not not a servicenow thing yeah and I mean please foreign Ah that's probably it oh I guess imagine because I was I was looking at this yeah but the service now supports the match all right well uh are you on uh are you still in scoped is that not part of JavaScript uh no you're right we could but I tried match all right and it just don't do anything so maybe match all has a different well I don't know if you need the g in it because you're if you're matching all that I thought that would be a signifier to to you everybody where was the you sent me this right yeah it's just right there at the bottom match all our exact the bottom we're going crazy match oh match up um okay so I mean match all sounds like it it would be nice natural yeah but I don't remember this ever being a problem with Rejects I mean it's it's probably a US issue so like because that like because this looks like standard JavaScript right take this so oh so it's not yeah because it doesn't do um you just create you don't yeah just create a a variable or whatever yep and then we just need okay so we already have the string so let's make this string we'll we'll go to fancy stuff again [Laughter] so now we want this stop match all of the regex right of the regex yes stream.match all regex and then we're just going to console log this should be an object okay so now if we stringify this object empty what so it doesn't even like doesn't like my matching it doesn't like my regex now what's wrong the regex should be let me just try something like super yeah like I should definitely find a yeah that should find it all right yeah that's really is that oh that's good enough it's like let me let me paste this code into modify the stuff yeah nice so if we have that extra long cool uh and then our regex is just gonna be okay let's see that oh interesting that is interesting so maybe oh I wonder I wonder if we have to escape that uh angle bracket if I remove it it's still picks it up yeah okay at least it makes me feel better that this didn't work that's a regex problem yeah foreign like match yeah interesting but in the generator we were getting it to match correctly right yeah this this one looked like it matched completely fine maybe multi-line you know why is because um it's it's matching it is correct you can see that it picks up the colon 13. uh that's why you get all that yeah but so the match is correct right like hovering over this right it says group one should be the 13th group two should be everything else oh I see yeah that I don't understand why it's not giving us group two maybe uh match let me add a g and mad and yeah it's just like ideally we should so the zero is there but the one isn't there thank you yeah so there's something that's really odd this like grouping part isn't isn't working yeah so yeah well we're out of time and it's all your fault well maybe maybe we'll do another one um once we we figure it out it goes to show that using the internet doesn't always work as well as we planned it well and servicenow puts arbitrary rules in place but I I I I don't know I feel like it's part of regex I'm always I struggle with that like it's always like I spend a lot of time if I have to build a regex because it's just one of those things I don't I don't keep in my mind and I think that makes sense like I think at least what was good was we are able to like get the unload away right so all we really need to do concatenate the string like I wonder if I can just XML string to this but the the problem that we're gonna run into now is so it added it yeah and now you would need to put oh you need to pull that that out but we could probably do that easier God's two equals XML string dot replace all oh but this needs are you removing both instances of unload uh well no I was gonna remove the this part of like like that so like if we're in Rejects we want to remove the so if we get rid of this it's like everything before this right so you would do um the bracket so do another cap do another thing there um yeah and then do the angle question mark now the angle the angle bracket first angle bracket oh that one no no no no angle not a square the alligator no other way left side and then XML and I think you have to escape the question mark because it's a uh and then in there do uh another curly or another round bracket inside parens with an asterisk or dot asterisk no not there in between the other yeah right there wow that is impressive that is impressive I'm I'm in shock I was but I could just pull that but I could pull that off out of my out of my head I'm in I mean I mean but now I don't even know how I would I think I need to put this on its own thing now so it's the same idea you do the you do the forward slashes yeah bridge to with this Dimitar is wondering if we can use starts with and then based on the index to remove it good good question this didn't uh replace what I wanted to oh but I think it's because I have this actually there we go oh my gosh look at that look at that so food too this is gonna be beautiful so we're replacing that with I think you can I think you can chain all that too can't you so this is xml2 we're replacing that with empty and then oh okay that with food too all right I think then we just need a print view I think this is this is our winner so we got the XML we got the unload and I think this is gonna look correct I'm gonna be in shock let's show this guy again and I think there's a way to format this document oh wait just like to do word crap I should have thought it was uh I wonder if there's a I think it I think it I think we got it did we did we just pull it out I should have made it prettier let me oh here try this um select language XML bam see if that see if that makes it prettier now I need to go back to this one and then I need to switch my screen and oh it oops got it hey look at that so I think I think that unload isn't that the uh attribute yeah which I think is fine I think so I think this would would work so we got the two incidents so yeah let's let me save this and testing um oh use your less used PDI to import it in case you totally did kill it I think I wonder if so I I wonder if this oh I just like crashed well it wasn't it wasn't that big of a XML was it apparently I had 40 gigs of memory attached to my my window well I was I was going through that problem for the past two days like my Mac would sound like it was taking off every day I'm like what is causing the problem might close all these tabs but once I unloaded my browser and then uh cleaned it up it finally turned off the jet engines yeah that's that's crazy um so I mean really what's left is I just need to share that screen again is just uh importing it and I think we're I think we're good um this way it still thinks that is this the right it's not the right screen it's lying to me it's like uh there we go it thinks that old screen's open okay so so now if we go to incidents thank you um and I don't I shouldn't have these uh incidents in here um but we're gonna just go by updated yeah it'd be updated are you showing the other did you have another like where you were showing the the names of them or whatever hey oh look at that now do they open do they open and can you update them let's make sure they're like actual good records that aren't going to be all weird I mean this looks good were were there work notes that were associated with it too uh so there's so there's this work note and that one came over and this one didn't have a work note uh which it doesn't right we did it so wow I mean sure there are things you know we could totally make it better but uh so so really so we figured out the technical part of merging them right the second thing we need to do and maybe we do a part two is we just build a nice little interface that yeah you can like drag and drop xmls together and it'll merge it for you and that's more on your side right yeah I mean we could do a portal interface sure like a simple like just drag I feel like the drag and drop would take like hours but uh you know we could do something simple like you know like you just want to do a bunch of incidents right so we'd give them an interface with records they could check a box and then say merge yeah I think I mean or like a UI action right the issue that you have is like it's easy to export these right like when you want to uh export these records um like if you do let's see um if we do like a search in zero zero one or zero zero nine I think like here you can you know export this XML right it's when it's multiple tables that you're running into the issue so you really need to say export all of your things and then bring it to this tool and you know you know oh upload upload the disparate XML files and then give them a way to I see what you're saying yeah we could do that too that'd be kind of uh interesting I think it would just be a simple portal page with like the browse icon right like and it's just like like browse file here and like browse file I don't know maybe something about but I think yeah um kind of nice for yeah I think the biggest use case is like you did a bunch of data in uat and you need to move that records over for whatever reason um like this is this tool could potentially be a good one for you I got you oh I'm just glad that we uh we pulled it out at the end oh man it was so embarrassing my my reject skills here was was rough well luckily someone asked me a question about regex this morning and I was like oh because they gave me a snippet of code I'm like Oh you mean um something that's you know one or zero through nine and it's eight digits long and they're like yeah that's what I'm that's what I'm actually and I'm like well you got it but you can do it easier you could do um the slash d and then squiggly squiggly brackets eight but now but I was like I think you're missing the carrot up front to start because they had a dollar sign at the end but uh so it got me my juices going on regex that's that's the only one I was able to oh cool this was this was fun yeah yeah I think we should do more hack a day Fridays yes hopefully without regex so that my brand doesn't explode sure sure cool all right well um if you like this you know like And subscribe John and I have a lot more Tokyo topics coming up soon um especially when when GA hits um in a couple weeks yeah so um yeah we're super excited and if uh you have any ideas of things you want us to tackle or we're happy to do it and uh yeah all right we'll see ya wait we gotta we gotta get a a cheer in here thanks Dimitar for for all the help as well so yeah thank you [Music]
https://www.youtube.com/watch?v=EjfDogvXmfo