#1 TalkNow Series | How to decide whether to use business rules, client script, GlideAjax, UI policy
[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 light camera action this is what i say when i record my every video hello everyone welcome back to sas with servicenow this is my first video of my new series that is talk now in this series i will be talking about different topics in servicenow platform i will be answering lot of your questions which you have asked me in the comments in a lot of my videos so let's start with the first video of this series now it's obvious that when you get a requirement from your customers or clients now before developing that solution you have to first think that how that solution will be achieved okay that's a very important decision that's that will make sure whether your requirement will be delivered smoothly efficiently and with the quality and with the proper standards and in that case developer has to think whether he should go for client script whether he should go for business rules whether you should go for glide ajax ui actions ui policy now that decision is very important now in this video i'm going to help you that how exactly you can decide that what you should select or what element you should select to deliver a requirement and service now now before you before we understand the requirement or before we talk about what elements i should select in servicenow or to deliver a requirement it's very important to understand two different elements one is server side and client side because if you will understand server side and client side then i'm sure you will be able to deliver and think what exactly element you have scripting element you have to select to deliver that requirement because servicenow has a lot of scripting elements which are based on client service now also has lot of different elements which are based on server side now but let's understand what we have server what we haven't client now let's say because every user uses the service now on the browser service now opens the browser open the client that becomes the client so your browser is the client where user can take different actions user can click on submit button user can click somewhere you can user can change the field all those actions basically happens on client that's on the browser so whatever actions you take on the browser user takes on the browser that is a client side basically and if you have to do some kind of database query you have to do some uh calculations in the database you have to fetch some data from the database from different records from different tables that becomes server side because that's a server-side code that's a server-side processing which will happen to fetch the data if something i have to get the data from the database that basically becomes the server side so these are the two different elements client-side and then server side now servicenow already provides different elements as i mentioned and the client side we have client script ui policy we also have basically glide ajax it is definitely you fetch the data from server but you put it on the client in inclined side you also have ui actions but your actions uh uses both client and server it is basically both but if i talk about server you have business rules you have a script includes you have um i think flows as well if i talk about flow designer floor designer is also a server side all those server actions you take with flow designer they're all server side because that's what you do now how exactly you will decide so now when you get the requirement so let's say requirement is customer is looking for a button and when you click that button it should show some message on the screen but that message should come if if priority is uh p1 let's say that's a that's a uh basically use case or that's one of the requirement you get so if the incident stay a priority is p1 and if customer clicks that button then customer should see a pop-up maybe it's just for validation whether it's a p1 or not now this is definitely a client side so you have to think okay user will see this pop-up on the client action will also be on the client but the only thing which user will get it's i think the data which is already on the client as well because you already have that value on the client so you don't have to use server side at all in this case because when form is getting loaded you have all that data in the client itself in the browser on the screen so in that case you won't use any kind of server side it's all client but now when okay so we have sorted out this one that it is overall client but now what next that how should i go for should i use ui policy or should i create a client script now the important point here is you have to create a pop-up and if i click on that button so or do i need to create a ui action now we are talking about the button here now in service now button is a ui action which could be in the related link which could be in the basically on the form button as well so let's say you have to create a form button so you have to create a ui action with that ui action you can definitely maybe if you just want to show alert you can also do that but i would always recommend to use these kind of pop-ups with ui pages so create a ui page create a ui action call that ui page from this ui action with the help of glide model so you call that a ui page and then this pop-up will be popped up in the front in front of user now let's say uh let's talk about another use case in which if i open a form and we have a caller field on the incident form and if that caller is a vip user then i should see a message on the top of the form how will he do this because i can't see because i just see the user id of the user in that field so i can get that data but i can't get whether that user is vip or not now in this case server side script comes into the picture why because we already have a user table which stores all the information about user so in that case what you will do you have to fetch the data whether that user is vip or not so there is a field which is called as vip if it is checked if it is true that means user is a vip if it is false then user is not vip so in that case you can use three things in service now one is get reference another one is g underscore scratch pad and third thing is glide ajax however in this case you definitely need uh you that data on the client so you have to create a client script and that could that would be on load client screen why why on load the reason is because you are loading the form so you're opening the form form is getting loaded and then you want that pop-up or that message at the top so in that case you will write a client script which will be on load and when form is getting loaded in that case then you can write so you have to maybe face the data as i said you can also use get reference but get reference should be used with callback function you can also use g underscore scratchpad but for g underscore scratchpad you have to create a business rule because you have to create a display business rule fetch the data and then you can use it in the client script but overall if i if i talk about how you can deliver this requirement so you can create a client script and or if you are using glide ajax in that case you have to use script include that is also client callable and so overall you have to i think deliver this requirement with two things one is client script that is that is the mandatory thing because this requirement will be delivered by client script but second thing can be a glide ajax that means a script include or it can also have a get reference but for that get reference you don't need any other element you can use it in the same client script as well but if you're going to use g underscore scratch pad then you definitely need a display business rule which will store that data that means whether the user is a vip or not from the server store in the scratch pad and then you can use that or validate it in your client script so i would say maximum two scripting elements which will be used and minimum one that is client script which is the mandatory in this kind of requirement now you could have let's say you have a different requirement in which you have to create some uh incident task so let's say in when incident is created or maybe that incident is assigned to a network team in that case you have to you have a requirement in which you have to create two incident tasks automatically nobody would do it and manually it would be done automatically now you have to think again that how this requirement can be delivered is it the client is user doing something on a client no you in this case you are doing everything on server you create the incident which is definitely in in the database you create the record once record is created then you create two incident tasks and that is again server because you are inserting a data into a table that's it so client is not at all in the picture because i i'm not populating anything i'm not in this required you don't have to populate anything uh to the user on the client if you will create it it will automatically show in the related list so in this case this is purely server side first thing so now we have that understanding we have to go only with server side type of scripting not at all ui action no uh because there's no button so we don't have to use ui action we will not use client script will not use ui policy what we will use business rule now this can be achieved with business rule or flow designer as well so you can create a business rule on insert or even you can do async as well so when in when incident is inserted then you can create uh incident two incident tasks which are basically assigned to some teams that you can mention in your script so minimum you have to create a business rule or if you want to go with flow designer that is also really easy you don't have to write any script in flow designer you can also mention event will be when record incident is inserted with a condition and then in that action you can mention create records and then you can create two different records in the flow designer now whole requirement is delivered with business basically server side scripting i would say but flow designer is not at all uh not at all scripting because you can do it uh without coding and that's a powerful feature we have in flow designer so that's how you can decide what element you should select while developing a solution and servicenow as a developer or servicenow administrator so i hope you like this video please do subscribe my channel and share my videos and please put the comments for any question you have i will definitely answer those questions in this series thank you and have a great day
https://www.youtube.com/watch?v=9KDmxjplFhM