logo

NJP

#1 SERVICENOW JAVASCRIPT TUTORIAL | LEARN JAVASCRIPT FUNDAMENTALS AND BASIC THAT USED IN SERVICENOW

Import · Aug 16, 2023 · video

Hello friends welcome back to my YouTube channel basico service now learning so in this video we are going to talk about the JavaScript we use well scripting in service not platform in this JavaScript tutorial series I will be focusing on JavaScript fundamentals and Basics we should know while scripting in servicenow platform so let's begin so friends in service now we do Platform scripting which means by using JavaScript we can do complex configurations and behavior in servicenow platform so the question is that what is Javascript so let me give you a brief of it in terms of service now first so JavaScript is an object oriented scripting language which runs within a browser and it does not need a license JavaScript engine in service now supports the Acoma script file and acuma script 2021 standards okay so here the another term which is mentioned over here is complex configurations so in service now platform service not recommend to do configuration first so if the configuration is not possible then the script comes into picture to achieve the specific requirement so let me give you example of it first so let's say you receive a requirement in service now where you have to implement something so what you have to do first you have to make sure that whether the script is needed or not is there any way through which you can achieve the same you have to see are you able to achieve 80 percent of the requirement via configuration instead of scripting if yes then you have to go for a configuration or if the answer is no then you have to go for a scripting for that complex configuration okay so let's see what all things we are going to cover in this series but all JavaScript fundamentals and Basics we are going to learn in this service not Java script tutorial Series so friends this is table of content the first is important overview and setup we are talking about the same currently then we have variables automatic operators string and spatial characters data type conversion if statement and Boolean logic ternary operator switch statement while loop for Loop do while loop nested Loop functions try cash parallel statements database query arrays array for each common array methods array utils most importantly object array of objects Json stringify and parts recursion classes passing object to functions class inheritance scripted rest API is currently I have made a list of 27 concepts by going forward I will be adding more Concepts into it but if you have practice all these 27 Concepts believe me you can easily do a scripting in servicenow platform so I think now we are good to go so let's see what is the first requirement we should have prior learn scripting in service now so the first thing is the personal development instance I believe if you have that then it's okay if you don't have that please create a personal development instance service now I have already created a video for the same you can refer that video that how you can create a personal development instance okay first you have to to create that and you can also install an extension that is SN utils that is optional but if you are installing it definitely it's a tool which will be helping you a lot while doing a scripting in service now there are few other questions which we should know before starting with our first script the questions are when to write the script as I already discussed you earlier right when to write the script the another question is where to script execute you should know right where you have to write the script and from where the script execute right you should be aware of that the third one is who can script in service now there are specific roles the person who is having that role can only script in service now we will be also talking about this in this video so let's see when to write the script so you can write the script when there is a requirement to add new functionality when you have to make some changes in existing functionality or you have to automate the processes or if you have to interact with the third party application then you can write the script these are the few scenarios where the scripting is required But first you have to make sure either it is possible through the configuration or not if it is not possible through the configuration then we have to make it possible by writing the script in service now platform so let's see the another question that is where do the script execute so the script execute client-side so client-side scripts have access to data on forms and in list so let me demonstrate you in service not platform first so friends this is my servicenow development instance so as mentioned in the slide that client-side script have access to data on forms and in lists so forms are basically these these will be called forms okay and these be called list okay so client set script can be written in client scripts UI scripts and UI policies okay so these are basically the areas where we have to write the client script let me give you example of it client script you can type plant script in this filter Navigator see here so here we have a client script section if we want to execute something on a form site or something on a list site we can write that code over here just you have to click on new and then you have to give some information here we have a syntax editor where we can write the code okay there are other sections too like UI scripts UI policies and Etc where we can write the client script so what all we can achieve through the client side scripting is that to show or hide fields for example in a form let's say if you want to show some Fields let's say you want to show category Fields you can write the code over here is there any other field you want to show you can write the code over there okay the same you can perform through UI policies also and if you hide some field you can write that code in client script or either you can perform the same activity using UI policies okay so later on we will be covering those step two even though I have also made a video on UI policies and client script you can also refer the same to get a more understanding on that part this tutorial is related to JavaScript so I am just giving a brief of it that we are all we can write the script what is basically client side what is basically a server site right just to give a better understanding prior starting learning the concepts of JavaScript for service not platform okay here now another we have a server side scripting means if we have to deal with database records it means if we have to create a record if we have to read or record which we have in the database if we have to delete the record or if we have to update the record then whatever script we have to write that is basically a server side scripting server cell script we can write in business rule we can write in script include we can write in script actions and Etc same as client client script we also have a section for business rule where we have a syntax editor we also have a syntax written scripting tool we have to write a script over there okay so for business rule and script include understanding you can also check the videos we have that in our channel so through server side scripting you can trigger a flow you can modify a database record and you can do lots of other activities we will be taking care of all those things while implementing their things because whatever we are learning in JavaScript we will be learning through some examples right so so probably those areas will also be covered there the another one is mid server let's say if you have to integrate with third party application then for that you can also write a script over there let's say you have a scripted API where you have to write the code right so in that way you also have to write the script over there now the another question is who can do scripting in service now platform so the first and the most important person who can write the script that is system administrator user with admin role who manages all the features and application and data in their platform that is system administrator and the rule required for that is admin the another person who can do that scripting in a granular level that is system definition administrator it's a more granular administrative roles who manages a specific system definition definition for example I want that XYZ person can only write script in client scripts he cannot write a script in business rule or in script include so I can provide a specific role to him so that he can only write the script on that section only so there are lots of roles let's say script include admin UI policy admin client script admin let's say if a person has a script in a client descript admin role then he can only write the client script he cannot write the server side script or if I want a person can only write the script include then I will be providing him a role that is script include admin I think it gives you a better understanding right now the another person is application administrator okay so the application administrator is managing all the features and data of any application custom admin role to administrator who maintain that application for example hrsd CSM there are specific applications where a person has a specific application administrator role from that roles he can only manage that application he cannot manage the global application so I think we are done with the three questions so we are ready to go with our first script so let's understand the same practically so friends let's navigate to servicenote development instance so this is my service now personal development instance as I showed you earlier okay so here let's type background script first so in this background script we have a editor okay this is displaying as this particular UI because I already have a SN uterus in my browser okay so this is basically a syntax editor which basically allows you to run a specific code just to test and see whatever outputs you need okay this is basically just to check the code or just to see whatever you want to achieve prior going to write in different sections like say business role script include what you can do you can write a piece of code over here in that manner let's say GS Dot uh info and you can just print a message that I am running a JavaScript for service now platform and just run it see in that way you can write a code and see what exactly the output okay so now let's see the other sections where like you can write the script as we have said earlier that a client description so go here type client script let's say if you have to try for a client script let's say this is client descript section open the client script here then go to new okay so let's say I am telling you a very basic syntax currently just for understanding let's say client JavaScript obviously client is site JavaScript okay so let's select the table incident you can select the table accordingly the requirement let's say if changes needs to be done in a problem changes has to be done for a change management then accordingly the table has to be selected I am giving a demonstration so far that I have selected an incident early there is a UI type that what areas where you are looking for mobile or desktop or all okay and there here we have a syntax editor where we can write the script so let's select what kind of client script you are looking for I want the client script which basically execute on node means every time when the form loads the script gets executed so give I am giving a very basic profit currently alert I'm saying let's learn service now JavaScript okay only single sentence and let's save it so once we are loading the incident form see this one so every time it will be displaying as an alert see in this way okay it's a very basic very basic alert only just for understanding that where we have to write the script for that I am just giving example okay let's say if you have to write a server-side script you can write that in a background script also just to check or either you can also write in the business rule so I'll giving you a server set with script example uh in a background script okay here earlier I have given to write so let's say server side script is basically just to deal with the database okay so I'm saying where gr equals to new the light we got and I am also taking example of incident over here that is i n c i d e n t okay so you are assuming that this is this client record is a JavaScript no it's basically a service not class but this where gr is basically a JavaScript okay so here I am saying gr Dot add active query you can gr dot query while gr dot next okay GS dot info and gr dot get value and I need a value of number so here I have written some code now you are thinking that we are the JavaScript and what all is happening right so let me give you a brief operative first that I have just written the code just to give a understanding of a server side code but how we can write that code and how we can achieve the thing we will be starting learning JavaScript Concepts but just for example I am telling you that in that way we can use a basics of JavaScript in service now platform so here you see Y is basically is a syntax of JavaScript where is the syntax of JavaScript right okay in that way we will be using other concepts of JavaScript while doing scripting in service not platform so here what we are doing this is basically a service not class that is slide record which is basically used to deal with database this is a table name over here here we are saying that using that object that whatever active records are there filter those records by them the then we are querying database and we are saying print all the database while we have the records in it okay let's run it so it is displaying me all the incidents see those who are active in a instance okay in that way basically we are using a JavaScript with service now classes okay to achieve the required thing I believe now you have a idea that in what Manner basically we have to JavaScript so we are not going to learn each and everything that JavaScript have we are going to learn in this series that what all Concepts what what all fundamentals basically we need to do scripting in service not platform and believe me after learning all those 27 Concepts while doing scripting you will find it very easy to implement the requirement basically we have covered the first section that is important overview and the setup in the another session we will be covering the other topics okay the the content which I have shared in this PPT I have posted all that content in my website that is I have shared in this link and I will also sharing this link in this video description you can find those links over there and you can find all the details which I have given uh in this video the content and all the scripts section okay friends so friends if you feel that this video is helpful for you then only please like And subscribe and if you feel that this video is not helpful then please provide your suggestions and feedback in below comment section so at least we can add other things in our video so that at least it will be helpful for you but thank you friends have a nice day bye bye take care

View original source

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