ServiceNow Introduction to GlideEncrypter API | GlideEncrypter API with the use case | ServiceNow
[Music] hi all and welcome back so in today's tutorial we'll be looking on one more use case okay this particular use case i encountered in one of my project okay so this particular use case talks about a user okay who want to update that database so as it was a frequent request from a couple of users right so we asked them to create it via incident and i'm just giving a use case you can mold it out the way you want okay so in order to resolve that particular incident they want to give they have to give username and password for the database then only we can up to the update activity right on the database and it's a confidential information so what we have did as a part of that we have given them the provision that as soon as they provide the password okay we can't mask it out also because then it will be it will be visible for the admins so what we did as soon as we um as soon as they pass on this information we will encrypt that information store the encrypted information within the field and then how the others will decrypt right okay how the people who want to work on that incident who will resolving that incident will come to know about the password so for that we'll be creating a ui action okay or you can call it as a button which will be visible for the group only and they can simply click on that button and get the password decrypted for them pretty simple use case okay you can you can mould it out the way you want as per your project requirement so i will be giving you the demand the same so we will go to the incident form so i will go incident run 2 and what we have done if you see we have created category called update database okay in the category and if i click on the update database we have added a validation that it will pop up two fields two fields will get popup username and password okay and if i currently if i select this filled out okay so for example i i will give it to user able tutor again it says demo data and i will give username as username and password password and if i save it out in on behalf of able to run now my information is pretty exposed to everyone user and password right and in our case we have database also that means it gives all the information so let's work on the same so what i will do i will duplicate this timeout first of all and we will go to the incident form i will simply right click configure will write a business rule on the same says got to the business rule and on business will be creating a new business rule to encrypt the data first okay let's work on encryption then we'll try it how and then we'll see how to decrypt it and we'll give it a name as technomonk [Music] script i'll be doing it for password only now the similar way we can do it for username also encrypt password i will go to advanced view i will give before before i insert update i will give both i have to give the category as i will add the condition as category as update database because then only those fields will get popped up and i can do one more thing and what does i want to do password for now we will go with the password password is not empty because if it's empty then on which particular thing i will do the encryption right so this is done now moving on to the code so the code is pretty simple so variable script equal to i'm invoking the script include for encryption which is glide encrypter so equal to new glide and script and now what we'll be doing we will be invoking we will be encrypting this thing so variable a variable in crypt data password password equal to in encrypter script include we have a method called encrypt okay so we'll be using that method so i will give encrypt dot encrypt so this is the don't get confused between two enclaves okay the first script is uh spelling mistaken grip which is the um which i create an object for the scripture and now i'm calling the function called encrypt from that script include and in english we have to pass it has it takes one argument which is what particular string you want to encrypt okay it has a string input so we'll be giving as a username so i will do current dot get value of what of a password so the field name for password is underscore password done now as a part of this we think in encrypted password we will get the encrypted password only okay now we'll be setting this value again on the us on the password field so for that what you can do current dot set value set value for what will give you underscore password and what should not white skinny ass sorry okay and do what so we'll give it a encrypted password done so this is all for the script we don't have to write current dot update because it's the on before business rule right right that's on before business is perfect so let's just save it out and now let's create a new incident so i will do incident dot 2. and we have a new incident form so let's select a caller first so caller will be again making a culprit to our favorite table tutor i'll give category as update database username we will again give a username and password will give password okay and short discussion this is demo demo record none and if i save this out now ideally it should encrypt the password okay so you you should not be able to see the password as this like this so if i save it out oh it got encrypted perfect okay so this part is done now what is now we a person able twitter has created an incident and he is secured that his password is encrypted now what if uh how that particular team who will be working on this particular incident will decrypt this password so we have to create a provision for them also so that they can decrypt this password out so for that let's create a new action so we'll create a new action let's create again configure in configure code to view actions and in your action let's create a new your action i'll give it a name as take no more decrypt now people will ask i i'm doing my branding okay but it's not that thing because i've created so many custom components right so i get confused between the after the box component and custom components so just to differentiate i'm adding this as aberration so decrypt and uh we want to do the form button we will not go with all these things okay actions and all these things and we will simply write simple script so we don't want to update that password field we'll be simply showing it as a info message so i can go yes dot add and for message and in that will what we're doing we'll be directly calling that script include so i will be doing the script password colon space plus it will be new glide we have the similar wave the way we had encrypt function we have a decrypt function so we'll be using decrypt and now it asks the argument what do you need to decrypt so for that we need to provide an encrypted string so that will be current dot get value get value of what circuit value get value of what so for that we will be providing you want discord password i think this is done one two three i think one one additional okay it was right only so we will and one more thing i missed okay so we want to set rate like url also so i will do action dot set create direct url correct url redirect device what so we'll give it as current and done so let's save it out and let's see if we get some button on the form no need to write define script your actions and all these things so we'll go back to our incision form and we'll reload the form now and now we can see a button called how techno want decrypt okay if i click on this button so ideally our expectation is like it will decrypt this particular password so let's click on this and now you can see the decrypt password is password isn't it amazing okay so this is how how we can we can enable the encryption you don't think that from where this is coming this is coming from the util uh extension okay so this is all for today's tutorial okay hope you like this tutorial okay please drop your use cases so that i can create uh some videos okay or some reference videos on the same okay till then stay safe stay happy and have a nice day thank you you
https://www.youtube.com/watch?v=L-9EK4h_9Ec