logo

NJP

Comparing Records with Hashes or Fingerprints

Import · Dec 19, 2023 · video

[Music] hey everyone it's Justin thank you for watching and welcome to my house in this video I want to talk to you about something unusual and it is a scripting function that I've incorporated into an action in flow designer which I've incorporated into a subflow in flow designer which I'm using to manage my application craws of the service now store and I thought this was actually relevant because uh I have the problem before me of how do I compare one record in service now to another record in service now and the best I could get was basically comparing hashes of those records um a hash of the record is basically you use an algorithm to look at all the values uh of a of a input and then create a hash for it and then you can compare two things really quickly without having to go if this field matches this field if this field matches this field if this field matches this field so what I wounded up using was Glide digest it provides methods for creating a message digest from strings or input streams using md5 sha1 or sha 256 or sha 1 sha 256 hash algorithms so that is what I used let me hop over to flow designer and show you what I did I made a really simp simple action called create application fingerprint it accepts as an input a string that we're going to fingerprint and then it outputs the H fingerprint that's it really really simple it's got one step okay so we populate a variable in the script step we pass the input that we got here to the input of the script step right that's how you got to do if you're using flow designer and then all I do is I call that class that we just saw I make a new variable called digest make it a new Glide digest and then I passed that string and put that in my output so I should explain this a little bit further right here I'm saying use that digest uh class that I just created and use the method get sha1 base 64 I have no security needs around this I'm purely using it for comparing things so I don't care how secure it is and then I pass it some inputs and this is a string that I want to fingerprint and then I put that string in the outputs for the fingerprint hash so if you scroll down below we can see the outputs fingerprint hash is what I'm referencing there in the script above and it puts that in the output now where I'm using this if we take a peek at my application crawler shout out to Mr Jace Benson who by sharing some details with me about how my crawl was working and what he knew around rest calls and seeing what's going on and the inw workings of web pages my crawl now went from 12 hours to finish the crawl of the whole store to less than an hour 48 minutes is the last time I calculated but during that process now I'm going to I'm creating an application fingerprint and I'm passing all the values of the things that I want to know if they change or not so I might want to know if the if it's allowable on a developer instance if the application name is changed if the company name has changed if the version has changed if it's a service now app has changed all these things the price has changed so it's putting all this into a string and then I'm creating a hash and then I'm storing that hash in my application table so look at this I've got application fingerprint now for this particular application called configuration Hub if I scroll down and I might have to move my head here um if I scroll down and look at the application crawls look I've got a crawl here where the application fingerprint matches the application fingerprint here so now when I'm doing comparison using uh to see what's updated I can go hey does the last crawl value match the application fingerprint value if it does there's nothing to see here move on go to the next application but just below that you can see um the crawl there from yesterday and this is just because I've been building my application the fingerprint was different so that fingerprint does not match that fingerprint and so if my logic sees that it's going to update the store application and create a new version which is what happened in today's crawl it created a new version because look the previous version didn't have the application name or the company name or the price or is it a service now app because I'm just still building all this out so now I can have a true version history I've got this throwaway data of my application crawl histories and I don't have to do that if this field is changed if this field is changed if this field is Chang if this field has changed now I just take one swoop at it I make a fingerprint and now I'm comparing fingerprints between records and that is saving my crawl a lot of time so I wanted to share that with you whether what application you have to use it for if you're crawling or you're trying to do some kind of record comparison in service now don't forget about this Glide digest and the ability to create hashes is using uh some predefined algorithms for md5 sh1 and 256 in order to create what I call a fingerprint or a hash for some values I hope you found this video helpful if you did please like Please Subscribe or share with somebody who you think might be interested in creating hashes or creating fingerprints for their data and service now and until next time don't forget to always be learning [Music]

View original source

https://www.youtube.com/watch?v=pj8jzjsS0R4