logo

NJP

#1 What is Business Rule in ServiceNow | End to end Tutorial of Business Rules in ServiceNow

Import · Sep 15, 2020 · video

[Music] in order to subscribe to my channel please click here or click here please share comment and like my videos and channel hello guys welcome to sas word service now this is short studies of learning business rules in service now and that is also in details in this series you will learn about different types of business rules their major scenarios and practical examples overview of business rules we will start with overview of business rules what is business rule in service now a business tool is a server side script that runs when a record is displayed inserted updated or deleted or when a table is queried the table of business rule is cis a script where all business rule records are stored you can use business rules to complete tasks like update the value on a form automatically when specific condition is met or stop user for updating a record if condition is not met types of business rule there are four types of business rule before after async and display these types are basically the time when business rules should be running we will talk about them in details later two steps of business rule now business rule is processed in two steps one is when to run in which you configure the time when business rule should be triggered and another is action in which you mention the action you want to take when business rule is triggered which you can do via configuration or a script in when to run you need to define timing and operation to trigger the business rule so one is type of business rule in which you mention the time when br is configured for the racket being modified or accessed another one is type of database operation when both are met with the condition mentioned in the business rule then business rule is triggered and the type we have like before after async display and the operation we have is insert update query delete these are all database operations how business rule is processed so let's say user or system perform a query on a table then system checks query rules and perform that query and data is basically displayed as per the display rules on the form so first user queries the table and then data is being displayed as per the display rules that is about the querying but let's say form is being submitted then system basically checks before rules and then update the database accordingly that means before it updates something it checks for the before rules and then it update the database and then it also checks is if if there is any kind of after rules that means after updation of the racket after updation of the database what exactly what action it has to take as per the after rules let's see what kind of actions can be performed by business rules update the field value after creating the record as per the values of other fields that is one of the use case stop user to update or insert racket if invalid data is used if user is providing any invalid data maybe that something is not as per the validation you want to put then users should not be able to update or insert racket that's one of the actions performed by business rules display information message when record is inserted when you are inserting any record if you want to display a message on the top to the user on the form then you can use business rule as well that means that action is also performed by business rule and the next is create child task when parent is created that's another action now these are just kind of type of actions and scenarios which can be performed by business rules business rules now business rules can be configured without a scripting that means you can configure when to run like before insert or before update before delete you can do after update after delete that's something you can do with the help of configuration and then you have action where you have to set the value that means once condition is met that means when business rule is triggered as per the condition mentioned in when to run that is configurable in that case you can take the action in action section you can define that what values you want to populate for particular fields now the whole scenario which i'm talking about first tab that is when to run actions both are configurable you don't have to do any kind of scripting so with business tools lot of things can be achievable with configuration as well but let's say if any requirement is not achievable by configuration then scripting comes into the picture that means you can also perform scripting in business rules for which for the functionalities which you are not able to achieve with just configuration then you can basically use the advanced option and you can write the server side script in this script section ideally there's no spatial syntax for business rules however they are global variables which you can use to access data of records in your script so what global variables you can access you have accessibility and business rules so there are four global variables available in business rules current now this is something which basically store state of the same racket you're working on and then we have previous which basically captures the previous state of the racket you're working on before any update or delete so for example if there's any change in the value for any particular field that's something you can see and with you can access it with current and previous as well and previous is the basically previous state of the racket then we have g underscore scratchpad that is another global variable which you can access in business rule now the scratchpad object is available on display type of business rule that means when type is display it is used to pass information to the client and i will show you later as well and the last one we have is glide system which is again which is i would say uh the server side script which where you have different methods you can access different glide system methods as well so let me create a business rule with configuration and with a script this is my personal developer instance now i will go to list of incidents i'll go over here now i will create a new business rule so i will click on business rule and i will click on new here i will give it a name because we are going to create a new business rule but with just configuration first so if i put here demo for br and this is config i will check this box advanced now here as i mentioned you have this when to run and you have this actions so when to run is again configurable so i can mention what type of business rule i really want to create when exactly i want to trigger this business rule so maybe let's say i will do i will set uh a field value so i will do before insert and i set here if category is network and then i will go to actions and i will mention here assignment group so let's say you get the requirement then your customer says that on certain form if user selects category as network then that incident should automatically be assigned to network team that's a requirement so in this case you can use business rule and that is also without scripting so i will just mention over here like this and you're done i will click on save now i will try to create a new incident with the same condition so that we can check whether we are able to test it whether our our business rule is running successfully or not so i will click on create new and then i will just select the caller test for br and i will mention the network here okay i will not because that should be that should happen automatically i will just select the category over here so i'm a user now and i'm just selecting network category and uh that's it i'm i'm not selecting assignment group it should automatically do that that's okay that's our requirement so i will just save it if i will save it you will see that yes you can see over here it has automatically assigned the ticket to network team as per the condition that means it ran that business rule in the back end and it automatically assigned to this group so this is how you can create a business rule with configuration now i will quickly show you that how you can create a business rule with scripting so i will go back over here now let's say i will just i will just keep this category as network as it is what i can do i will now you can achieve a lot of requirement with these configurations like you can take the action with configuration but let's say you're not able to achieve it now this time i'm going to show you the same kind of script that means we will set the same group however you can achieve it but i'm just showing you the demo that's the reason i'm just using this script and as you will see this whole series further we will talk about in like these types of business rules in details with practical examples as well but even even with these operations different types of operations we have so if i come over here and let's say i am not putting anything here and i will just do current dot assignment group equal to now here we will put the society of this group this one so if i open this i will just copy the society that's it and i will put it over here semicolon and i will click on save you're done you have just set the value and we will just close this one and i will create a new incident again i will select the caller adam and then i will do test for br with script i'm not basically touching this fields i am just changing the network that's what our condition is and then if i click on save you will see it has basically taken the action i'm able to achieve the functionality as it is but the only difference is we did it with configuration and with it this is something which is without configuration and overall we have done this with a scripting so that is the difference but you should always try to achieve whatever functionalities you get from your customers you should always try to achieve it with the help of configuration first rather than starting scripting that's a major i would say important point and best practice as part of the business rules and it's not just business tools anything in the service now which you want to create it's a business tool client script you should always do that in client script definitely you have to write the script but any other thing which you can achieve with configuration you should always go for configuration first and then scripting if you're not able to achieve the requirement with configuration then your next priority should be definitely scripting that because there's no other way you can do that so in that case configuration should be your first priority and then scripting so this is how you can create business rules with configuration and with a scripting

View original source

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