logo

NJP

Introduction to ServiceNow getBooleanValue function | ServiceNow Client script tricks and tips

Import · Aug 09, 2022 · video

[Music] hi all and welcome back so in today's tutorial um we'll be looking on one of the topic which which pretty amazed me a lot so basically i was scrolling through the linkedin uh linkedin and i came across the post from vindaya belkauker okay here is one of our server top member and he shared some insights on one of the client script objects okay which pretty amazed me out so i will i will share it with you okay so for example if you go to let's go to this user dot list and if i open any records so let's take the example of ableton okay now it's not with respect to the user table okay it's with respect to the checkbox which you can see the boolean boxes right this checkboxes so if you perform a certain action on this particular action on the boolean operation if active is true product is false and performing certain action okay so you should be cautious about uh this particular this particular thing which i'm trying to share with you so i've been using java script executor so for example if i want to print this out in the client client script okay let's just try to define certain logic so i will not go and write some client script so i will use uh browser levels javascript executor for the same so if if you are not aware how to get that so it's available with all the browsers and the the shortcut for is like ctrl shift alt and j if you click all of this together okay so it will give this executor so what this executable does it works on client side okay on a browser level and you can define your logic on top of it so let's not waste our time in this and so for example uh i want to print the value for active so i will give a lot and i will just zoom out a bit it's gone too much okay and if i want to first of all let's see how exactly if i type you can type anything it works just like uh usual guys if i type hello in the alert alert and if i run my code it will give the alert handle so it just work as usual javascript okay so if i want to do it here just perform dot get value of activity so my expectation is like i should give true because currently it's checked so if i run it out let's see what i got true so you will say okay it's matching expectation but we are expecting the output number in format right okay because we want to define some operation on the boolean if it's true then what okay this kind of logic let's check the type of also this okay save file to you must be knowing how to check type of certain attributes so if i go with type of of g underscore form dot get value of active so ideally it should return boolean because it's a boolean field right if whether in my code it gives string amazing right okay so basically it's not giving uh your boolean output it's giving you a string output so and whenever it gives you string output when if you want to define certain logic so you have to compare it with the string so you have to give like if this particular thing whatever i would get is equal to equal to through the string now if you want now the things must be coming in your mind okay how i can get how can i extract the boolean values when there is a checkbox on my form so there is a function in in service now which is called as get julienne i will i will not i will just copy this out and we'll give one more alert and the function name is get inserted value you can protect boolean value okay of active and this particular syntax will give you a boolean output you don't trust me first of all let's see what if it's giving the proper output or not see if i comment this out if i remove this typo x and run it's also giving true right so both both of them are giving true now let's remove the alert out and i will add typo over here and now i will run my code so with the first logic get value it returns a string which is not a desirable output for us okay so let's look into carefully value and if we go with again boolean value function it gives us the boolean pretty amazing right i have never heard about this function but uh thanks to the post i got from vinayak i i i got to know this okay and um it's a lot it may lead to a lot of issues okay while you are using get values to valid to try some logics around boolean logic around any any client script right so just be aware when you are defining in logic for check boxes okay so this is all for today's video hope you like it out okay please like follow now to my channel to get this kind of videos in the future also if you have any queries just drop a comment and probably i will try to create a video on the scene and till then stay safe stay happy and have a nice day thank you you

View original source

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