give me examples of Before, After, Async and display business rules on incident table ?

gangasatishgurr
Kilo Expert

Please explain with the examples of All types of business rules

2 REPLIES 2

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Ganga,



These aren't exactly examples, but this is basically a simplified rule of thumb for business rules.


ValueUse Case
displayUse to provide client scripts access to server-side objects. For more information, see Scripting with Display Business Rules.
beforeUse to update information on the current object. For example, a business rule containing current.state=3; would set the State field on the current record to the state with a Value of 3.
afterUse to update information on related objects that need to be displayed immediately, such as GlideRecord queries.
asyncUse to update information on related objects that do not need to be displayed immediately, such as calculating metrics and SLAs.

Business Rules Best Practices - ServiceNow Wiki


Avinash_Patil1
Giga Guru

Hi Ganga,


i m trying   explain after business   here please take help to marketing   event application in learning portal



if the requirement is like that in   attendee table if record is inserted for any event then the count of attendee in marketing event table should be increases then we have to use after business rule on attendee   table.hope it will help you



(function executeRule(current, previous /*null when async*/) {



gr=new GlideRecord('x_180940_marketing_marketing_event');


gr.get(current.marketing_event);


if(gr.number_of_attendees_registered==undefined)


{


gr.number_of_attendees_registered=1;


}


else


{


gr.number_of_attendees_registered +=1;



}



gr.update();


})(current, previous);