Skip to main content

ServiceNow Interview Questions & Answers

    
                                                                                              
ServiceNow Interview Questions            

1.> what are best practices for Server Side Scripting?

  • Current.update() should not use in After BR – It’s calling itself over and again. 
  • Don’t use gr as variable in script.
  • Should not use GlideRecord  row count, use GlideAggregate.
  • Use conditions in BR, when to run always.
  • Don’t use global BR, use script include instead of that.
  • Script should not contain hard coded IDs.
  • Don’t enable Business rule on Table transform map until & unless required.
  • Too many workflows should not be checked out.
  • Read ACL should not have GlideRecord/GlideAggregate Complex workflow-not more than 30 steps.
  •  gs.sleep() should not be used in BR.
2.> Difference b/w Async & After Business Rule?
  • After BR executes synchronously, It’ll wait for a result & then user will get control to do anything whereas Async BR executes asynchronously, user will get control immediately, it will not halt the user and result will get displayed when its ready, it will be executing in the background as per system scheduler.
  • 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.
  • We can use current & previous objects in After Business Rule but We can’t use current & previous objects in Async Business Rule.
3.> Examples where After BR can be used ?
  • For updating the assignment group or short description.
  • To create related records like problem ticket etc.
4.>Examples where can we use Async Business Rule ?
Ex- create event & send notification 
1.>User is changing some field & basis on that event must be created and send notification to user 
2.> rest API call to other application when we create/update the incident in other system 
3.> calculating the SLAs

5.>what are best practices for Client Script?
  • Avoid global client script, client script configured on Global Table will be loaded every single time in System.
  • Avoid using DOM (using document. GetElementbyId) – it can cause maintainability issue when instance is updated – performance issue- instead use glide form API.
  • Use UI Policies instead of client scripts. 
  • Use Asynchronous call via get reference & Glide Ajax. 
  • Use scratchpad to minimize server calls.
  • Never use Glide Record in client script.
  • Should not contain console.log (), use js.log () in Debugging.
6.>How to show/hide any related list ?
g_form.hideRelatedList(‘related_list_table_name’);

7.>How to call another method in same script include ?
using “this“ keyword, Syntax - this.method_name();

8.>How to update work notes of related incidents?
As worknotes gets stored in Journal table, Use worknotes.getJournalentry(1)

9.>Create problem ticket through an incident ?
After BR – on insert () – incident table 
(function executeRule(current, previous /*null when async*/) { gs.addInfoMessage(current.short_description); 
var gr=new GlideRecord('problem'); 
gr.initialize(); 
gr.short_description =current.short_description; 
gr.state= current.getDisplayValue('state'); 
gr.assignment_group= current.assignment_group.getDisplayValue(); 
gr.caller_id = current.caller_id; 
gr.insert();
 })(current, previous);

10.>What is Display Business Rule?
  • Display Business Rules execute their logic when a form loads and a record is loaded from the database. 
  • It mainly use to store the Server side data & can be used in client side using g_sctrachpad variable.
Watch full video on YouTube: ServiceNow Interview Question Link



Comments

Popular posts from this blog

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...

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); } }

ServiceNow Interview Questions - real time

Let's see some ServiceNow Scenario based Interview Questions & Answers here, 1.> How to fetch latest 10 incident records ? var grIncident = new GlideRecord('incident');  gr.orderByDesc('sys_created_on');  gr.setLimit(10);  gr.query();  while (gr.next()) {  gs.print('check the :'+ grIncident.number);   } 2.>How can you populate caller_id in short Description on Problem form? Write Onchange client script on Problem table on change of caller Id field  var caller =g_form.getValue(‘caller_id’);  g_form.setValue(‘short_description’, caller); 3.>How to send notification to the user who is member of assigned group? You can write the below code in Advanced condition of Notification gs.getUser().isMemberOf(current.assignment_group); 4.> How can you populate the only users whose department is “Finance” in caller field on Incident form. Use Simple Reference Qualifier & select “department is “Finance”. You can write the code ...