logo

NJP

ServiceNow Glide Modal Prompt update pop up | ServiceNow Glide Modal use case with demo

Import · Aug 15, 2022 · video

[Music] hi all and welcome back to another tutorial so a lot of time we face a scenario where we uh we want to restrict the user from updating a critical data for example if we have user data okay and ideally the user data gets updated from our active directory but if admin wants to update certain things out on the user profile then we have to get a clear confirmation from the admin that he is that he is conscious what changes he is doing on the profile okay so in this kind of scenarios we need some kind of pop-up well you must have seen a lot of time when you try to delete some out of the box component in service now it gives us a pop-up very pop-up where it asks you to type delete and when your input matches didn't then only the record created so this is where we can call it as a ui principle okay where a person is worried twice okay now on what action is performing on that record okay so that he will not do any mistakes okay so let's try to implement the same so the topic for today's tutorial uh is like on the user table we want to restrict the user that whenever an admin strive to update any data on the user record okay then we give him a confirmation in that confirmation box when he writes the what we can relevant information then only we will allow him to go over it okay else you will not okay so let's go ahead so first of all we will go to the this user table which is a user table for the people who are not aware about it and this is our user table okay for example if you want to update the data for able tutor see if i open the profile available tutor so over here if i want to update this phone number okay so how i can do that i can simply give nine zero nine six one two zero i will not give my further so if i if i try to update it out okay it gets updated okay and if a person is updating if i mistake okay then it will mess up the system and he will not have a track of that record okay so how to avoid that so for that we'll be defining logic today let's get started so what we'll be doing we'll be using uh on subreddit submit line script with some of what we can say with some glide model class objects okay so let's go ahead configure i will go for client script so we will create a new client script i'll give it a name as if it's not then i can kill the name so we'll give it a confirmation pop-up i think this is the right name and we'll make it on submit it's active it's on user table we want to give all all types okay and now we got the script so we'll be defining our logic inside the script as a zoom out little bit so that you will be able to see properly so the first and foremost thing is like we will define this transparent variable so and we'll return true from that if it's true then we will return true so if why i'm doing so you will come to know ah so g underscore transparent dot action okay and i will true now we will this particular scratch pad when it turns out to be true then our action will get performed properly okay and if we return false then the record will not get submitted we know this basics right so we will define the logics around the same so let's define our slide border variable slide model equal to new slide model and we'll be using http called client.com [Music] it the title so i will select gm dot set title so what title we want to okay we will give it as great then gm dot will give set preferences so in preferences we can define in in our client model what should be what should the text okay what that type of instruction we want to give and then we can also define when we can define all the things all the ui actions and all those things okay so the first thing we'll be setting is i said that preference and preference first thing i will be setting it with title and i will what should be the title so it's why it's like you can say instruction instructions okay so we can give instructions please i'm sure or type in that right and sure if you then we'll be defining two button one should be the uh okay button okay and the second will be the cancel button whenever we have a pop-up glide water purpose we have this two button by default so we will define the actions on the two button so let's do that again instead of typing this out i'll just copy this out space two times because we want to define for cancel and for complete button so the first button will be on if they click on ok ok if they are fine so on prompt complete so on this what we'll be doing we'll be calling a function we'll give it a name called uh completed and the same thing we will be doing on prompt but not complete it will be on prompt of cancel what we have to do so we will give it a name as cancer pretty easy right so now we have divided the this two button or we can and then we will run by this glide folder so how we can render it out is pretty simple gm dot render done now we have to define two functions so first of all we will define the function which is complete okay which uh which executes the logic of the success code okay so let's do that so how we can do it is like function you know how different function like function complete and in function complete will be passing a value this value will be coming from the glad model and let's define the logic so yeah there may be two condition now for imagine there is a box okay it's giving you instruction text now you got the text editor where you can type that text also but now people are not perfect right users are not perfect so they may do the spelling mistake and we don't want to prove that if you are asking to type sure and uh they are typing over their okay and then also the record gets submitted so we have to do some validation on top of our data that also right so let's do that validation so first we will be defining our default method so how we can do the variable message which will be a default message and default is always the wrong message so [Music] wait we can hear pro you don't have given problem and we should throw the input also right so who input and let's give space plus what input here is given value sounds amazing right okay it is it now we will define if he has written if he has given right input right so value if value equal to equal to sure then what we have to do we will just set this as scratch pad variable out dot generously so what will be doing to true so first and foremost thing what you will be doing equals equal equal to true that means the record can get submitted we will give a message we'll update the message okay so we will update the magic then you i'm just adding it out now as a use case okay you can in your project don't type this kind of statements okay just use some business statement by doing actual development and then we will go with gsfp submit which is our favorite function whenever we are working on your actions and then don't use a lot of law of your logic just type what i'm typing it's done just conform dot okay element and then g under perform dot get get form get action what kind of actions it's update save so it will get those information from you so this is done and we will we want to just do the alert right so we will do alert what other method whatever it will be okay whether it's right wrong we have to just update the message so this is the positive risk as well a user is clicking on okay okay so in okay what we are doing we are calling a function complete what the function is doing its validating whether the input which a user has given is sure because we are asking them for sure if they are sure so we will be like okay let's project with update but if they are giving any rubbish value apart from show okay so we don't want to enter that entertain it out and we will give an alert key hey bro you have given a wrong input and we will just cancel the entire operation now the next thing is like if our user clicks on cancel okay so let's define the function okay ansel also and it will also have value whatever user enters here actually it doesn't make any sense but let's give it okay so we will do alert and in alert what we'll be giving the operation so we are not doing anything savage right run and we will by default return all hope that object is clear we have defined a sketchbook variable called action okay we understand action then we define glide model which will which will enter ask a user to enter show and it will have to button complete or cancel if it's complete then we are validating if the input given by the user is sure or not if it's sure then we are proceeding with the update if it's not sure we are just giving an alert and we are not doing anything on the other side if they click on cancel we are just giving alert and we are not doing anything i think that this is all uh for the scripting part okay so let's try it out okay and i actually use the record so it's getting saved confirmation pop up let's open our favorite user once again and yeah let's try to update the company for able to do so or i will give abel tutor one two three four okay to the email id now if i click on update it has given me a pop-up please enter sure if you want to proceed so let's go let's look on the uh in the descending order the first operation has cancelled if i cancel it out i don't want to proceed if i cancel here nothing will happen okay if i again do one two three and if i go for update now this time i will go for ok ok but i will give some random matches like xyz but i am not asking them for xyz i am asking explicitly for sure right so i should not submit update the record so if i click on ok it's like hey bro you have given wrong input xyz it doesn't make any sense for me if it doesn't make any sense for me so i will not update the record so the record will still be the same you don't trust me if i reload the record so you can see it didn't update anything now if i give one two three again okay again and if i click on update and this time i will type sure and if i click ok then the record should get updated so if i click ok so it gives hey bro you have entered sure so we'll update the record fine so the record got updated uh if i go one step back and close this out so you can see now the record got updated with able to do one two three so this is how you can add a glide model okay pop up on top of your any record any table record okay where you feel that of a person this up whenever a person is doing any action or whatever admission is performing certain action on this table they should be conscious about it what kind of step they are performing so you can have this kind of blog a blind bottle video okay i want to thank hugo first okay because i got the inspiration for this particular video from his article only so thanks a lot for the article okay hope it it will it will be helpful for others also and if you have any queries on the same please drop me uh comments okay i will all i will try to look into the same okay till then stay safe stay happy and have a nice day right thank you

View original source

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