logo

NJP

#1 Overview of JavaScript | Learn JavaScript With ServiceNow | A Complete JavaScript Tutorial

Import · Nov 15, 2020 · video

[Music] please subscribe to my channel and click on the bell icon to get the regular updates of my channel and do not forget to like comment and share hello everyone welcome to sas worth service now this is a new training for learning javascript with servicenow in this training you will learn javascript programming language and how you can run a javascript code in servicenow this training targets servicenow developers who wants to perform development and scripting in servers now to achieve complex requirements of customers and clients non-servicenow professionals can also watch this training to learn javascript in this course we will cover the topics like overview of javascript statements and syntax in javascript variables operators data types in javascript array objects conditions loop functions in javascript classes and regular expression and we will also see some other elements we have in javascript by the end of this training you will have a complete understanding of javascript language and programming however learning javascript is not the only thing needed for performing scripting or development in servicenow servicenow provides different classes and methods which you can call with javascript to perform different actions in servicenow in order to perform development in service now by using these methods you need to complete servicenow development training as well as this training will be focusing majorly on javascript language link of that training is already provided in the description of this video prerequisite this training has been developed considering no prior knowledge of javascript if you will not work on servicenow development you can still watch this training for learning javascript the only difference from other javascript training is that all practical examples of javascript code will be shown in servicenow application and in some cases they will be related to servicenow functionalities as well the first section of this course is overview of javascript in this section we will learn what is javascript why we need javascript in-service now and some more details what is javascript javascript is a popular programming language which is used for web development and change the behavior of the pages it is an interpreted programming language with object oriented capabilities javascript is mostly used for client-side development however you can also perform server-side development as well in servicenow you will do both type of coding in javascript why we need javascript in-service now javascript coding is used in servicenow to perform development on top of out of the box functionalities javascript coding is used when you need to perform integration of servicenow with other applications javascript is used when you need to perform some automation in servicenow if you are a servicenow developer then when exactly you will use javascript in service now so let's see the use cases showing an alert on the form if field value changes and push a value in a reference field if you need to copy comments from a parent racket to a child racket if you don't want to resolve incident until all child tasks are closed showing assignee values as per the assignment groups pushing the field value on change of another field value on a form now all these similar type of use cases which cannot be achieved via configuration need scripting in javascript language in service now where to write javascript code in service now servicenow provides a field with type as script which can be added on the form of any table you will find this field majorly on the elements which are used for different types of scripting in service now this field shows a script editor where you can write this javascript code overall this script editor executes all javascript code where to see javascript code output programming can only be understood when you see it practically with the output of an executed program as i mentioned earlier i will be showing you the output of javascript code in servicenow only with its different functionalities first one is browser alert which is triggered with the method written in javascript called as alert i will write the javascript code and you will see the output of that code in browser alert message second one is logs you can generate logs in service now with some javascript methods provided by servicenow and the last one is the main editor of writing javascript in which we can print the output by executing the code written in it i'm talking about background script which is a functionality to run server-side javascript code to perform some actions and you can write a generic javascript code as well i will also show you the output by updating some of the fields of service now forms and tables this is servicenow instance and it is my personal developer instance provided by servicenow browser alert is a client-side alert so i will be writing those scripts in client script functionality of service now to show the output in an alert method so go to client scripts over here so i will type client script this will open the list of client scripts we have in your instance i will click on new provide the name as test and mention the table as incident here i will select onload i will be showing you the output this alert will be shown when form will be loaded i will come over here and i will just mention a javascript code just one line of code that is alert and i can just type this is a browser alert basically we are using javascript code this is one line of code we are writing and here is the string which we want to print as an output so i will just save this client script is saved and now i will go to list of incidents so that i can open any incident let's click this one and when form will be loaded you will see that output in an alert so you can see this is a browser alert so it says this is a browser alert this is the same method same string which we used basically passed into our script and that's what i can see over here as an output so i can close this so this is one of the way which i can show you the output of the javascript code another one is logs so for logs if i type here logs and under transaction system logs you will see this all this will basically show you all the system logs so if i click this now this shows this list of rackets and this is showing you all the rackets in the system we have for logs so you can write the code in service now and you can generate the logs as well which will be basically visible in this particular list so whatever log you will generate it will be created as a record in this particular list so you can see whether logs has been generated so whatever code you will write like for example we wrote that alert rather than alert if i use maybe a method in which by which i can print the log in that case that this is a browser alert string will be visible as a record in this particular list now the last one is background script where we will show you all the examples mostly all the examples of javascript so if i come over here and i just type background you will automatically get this system under system definition you will find this module scripts background and if i click this you can see this screen which is called as background script so it's basically the screen which gives you opportunity to write the javascript code let me write a quick code for you so i will just make this screen a little bit big so that you can see the script now here how exactly you can execute the code so you will see here we have this run script button so whatever code you will write if you have to execute it then you have to click this button so in that case let me write a simple javascript code so i will write where a equal to 100 semicolon i will do gs dot print and here i will mention the java script code output is i can just do like this a semicolon that's it and i can just click this button so it will run this particular code that that means it will be the output of this code so if i click this you will see it has printed and it is displaying me the output same text which we mentioned in our script that means our code was executed successfully without any error and now i have the output so javascript code output is you can see it is printing the value of a which we mentioned in our code so that's how you can see the output of any code which you will write in background script and as i mentioned you will see most of the examples of javascript as an output you will see via this background script

View original source

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