Skip to main content

Posts

Showing posts from May, 2021

Difference b/w After & Async Business Rule in ServiceNow

Let's try to understand difference b/w  After & Async Business Rule & some examples on Real time scenario of After Business Rule & Async Business Rule : 1.> After BR executes synchronously (It will wait for a result, once result is ready & get displayed then user will get control to do anything, user has to wait) but Async BR executes asynchronously (user will get control immediately, it will not halt the user and result will get displayed when its ready or get response from system, it will be executing in the background as per system scheduler). 2.>After BR is used to update information on related objects that need to be displayed immediately such as GlideRecord queries etc. whereas Async BR is used to update the information on related objects that do not need to be displayed immediately such as calculating metrics & SLA etc. 3.>We can use current & previous objects but We can’t use previous object in Async rule & current ob...

ServiceNow Background Script

What is Background Script in ServiceNow ? Administrators can run any valid JavaScript that uses the Glide API. The system displays results, information, and error messages at the top of the screen & It can update the huge number of records at once.  Scripts - Background was this magical place in the platform where you could run any server-side script. You can update ‘n’ number of records at once using background script & It is kind of testing ground for any server-side method you wanted to learn about or new script you would like to test because you don’t have to configure When to run logic around it like a Business Rule. Running a script in Scripts - Background was as easy as putting a script in the field and clicking the Run script button.  NOTE: Scripts - Background should be used very carefully and only in non-production environments. Free-form JavaScript can negatively impact data and system performance. Try using Setworkflow(false); & autoSysFields(false...

How to use getreference() with callback function in client Script | #ServiceNow

What is the use of getReference() ? getReference() gets the record used in another reference field. For example you have the requested_for (reference to the sys_user table) and with getReference, you will retrieve the User record and save this as a gliderecord into a variable. Why we use callback function with getReference?  callback function allow you to use asynchronous processing with your getReference call. Example: FetchCompany&phoneNo function onChange(control, oldValue, newValue, isLoading) {    if (isLoading || newValue == '') {       return;    }  var requester_user = g_form.getReference('requested_for', callback); function callback(requester_user) { g_form.setValue('email_id',requester_user.email); g_form.setValue('manager', requester_user.manager); } }