- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Can anybody provide me some deep knowledge of client script , business rule , and server side that all interviewers may ask in their interviews. Some tricky scenarios or some deep knowledge .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @sagarpundir ,
1. Which type of BR shouldn't include current.update() and why?
- A "Before" and "After" Business Rule should not include current.update() because it runs before the record is saved to the database. When you update current in a "Before" and "After" rule, it can trigger the same rule again, leading to an infinite loop. This loop can cause performance issues and potentially crash the system.
- In case if you want to use current.update in before br then use current.setWorkflow(false).
2. Explain advantages of Asynch BR over After BR or vice versa.
Advantages of "Asynchronous" Business Rules:
- They run in the background, minimizing the impact on user experience.
- Suitable for time-consuming processes like data calculations, sending notifications, or integrations.
- Ideal for long-running tasks that don't require immediate user feedback.
Advantages of "After" Business Rules:
- They execute immediately after a record is saved, allowing for real-time actions.
- Useful for scenarios where you need to interact with the user interface, such as showing confirmation messages.
- Better for tasks that require immediate updates visible to the user.
3. Can we call a scheduled job from BR?
- No, you cannot directly call a scheduled job from a Business Rule. Scheduled jobs are independent processes managed by the ServiceNow scheduler. However, you can indirectly trigger a scheduled job by creating a condition in the Business Rule that inserts a record or changes a field that the scheduled job monitors. This way, the scheduled job will execute based on its configured schedule and conditions.
4. Did you ever call a script include in BR? Why do we call a script include in BR if we can write the same script in BR itself?
- Yes, it's common to call script includes in Business Rules. The main reasons are code reusability, maintainability, and modularity. Script includes allow you to centralize and reuse code across multiple Business Rules, scripts, and modules. This approach promotes consistency and reduces the risk of duplicating code. Additionally, script includes can be easily tested and updated independently, enhancing code management and troubleshooting capabilities. Writing the same script directly in a Business Rule may lead to code redundancy, making it harder to maintain and troubleshoot.
- Calling script include in br: var gr=new scriptinclidename().scriptincludefunctionname(any parameters you want to pass)
1. How do you debug BR? What are the different ways to debug BR?
- Debugging Business Rules can involve techniques like:
- Adding gs.log() statements to log messages to the system log.
- Setting breakpoints in the Business Rule.
- Using the "Script Debugger" tool to step through the script.
- Examining the system logs to trace the execution flow.
2. Explain any scenario where we can't use Asynch BR?
- You might avoid using an "Asynchronous" Business Rule when:
- Real-time user interaction is necessary immediately after record save.
- You need to show user feedback, such as pop-up messages, right after an action.
- The process requires immediate updates that should be visible to the user.
3. Explain any scenario where we can use Display BR instead of using GlideAjax?
- "Display" Business Rules are useful when:
- You want to dynamically show or hide fields, sections, or related lists on a form based on specific conditions without a server request.
- Display Business Rules execute their logic when a form loads and a record is loaded from the database. They must complete execution before control of the form is given to a user. The purpose of a display Business Rule is to populate an automatically instantiated object, g_scratchpad. The g_scratchpad object is passed from the display Business Rule to the client-side for use by client-side scripts. Recall that when scripting on the client-side, scripts only have access to fields and field values for fields on the form and not all of the fields from the database. Use the g_scratchpad object to pass data to the client-side without modifying the form. The g_scratchpad object has no default properties.
Type Use case Display Business Rule in ServiceNow:
Code written in display business rule get executed before the form is presented to the user and just after the data is read from the database.For e.g. you have written the code that when xyz user click on information box then only data related to that user specific country will get displayed to user. It means that user from US can see US specific data and user from India can see India specific data.
Before Business Rule in ServiceNow:
Code written in before business rule get executed when user submits the form and data is not saved in database.
Let’s say User click on submit button --> Before business rule code executes --> information will save in database.For e.g. Let’s say you have written the code that when user click on submit button then some extra information which in not filled by user such as user current location, user manager name and user past activities will get save when user click on submit button.
After Business Rule in ServiceNow:
Code written in after business rule get executed when user submits the form and data saved in database.
Let’s say User click on submit button --> data saved in database --> Now after business rule code get executed.For e.g. there is parent incident and child incident and you want that related child incident will get closed automatically after the parent incident get closed by user.
Async Business Rule in ServiceNow:
Async business rules are like after business rule but it runs in the background simultaneously with other processes. Means async business rule run after the data is saved into the database.
Running on background means that use can proceed with other functionality and code will run on the background which will not impact the user while doing other transitions.For e.g. Incident ticket is in pending customer action status and will be auto closed after 5 days if user did not provide any update on incident ticket.
display Use to provide client-side scripts access to server-side data. before Use 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. after Use to update information on related objects that need to be displayed immediately, such as GlideRecord queries. async Use to update information on related objects that do not need to be displayed immediately, such as calculating metrics and SLAs.
Please mark it as helpful if its works so it can benefit the community.
Thanks,
Abin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @sagarpundir ,
instead of asking what there might be in interviews, a better approach would actually be to deepen your knowledge in these areas if you’re not confident in them.
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
I would recommend you go through the client-side and server-side Glide APIs, and go through each type of script and their subtypes used in ServiceNow. For scenario-based questions, I would recommend you practice on ChatGPT — ask it to provide some basic scenario-based questions for PDI, then intermediate level, and then expert level.
PS: First make your base stronger, then you will be flexible to learn more and more topics, but the base should be strong and clear.
Note: Nowadays interviewers must ask about calling Script Includes through the client side, so you must be good at how to pass the parameter and get it, because if you know this topic it is assumed you know simple scripting for sure.
Hope it helps!
Shashank Jain – Software Engineer | Turning issues into insights
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @sagarpundir ,
1. Which type of BR shouldn't include current.update() and why?
- A "Before" and "After" Business Rule should not include current.update() because it runs before the record is saved to the database. When you update current in a "Before" and "After" rule, it can trigger the same rule again, leading to an infinite loop. This loop can cause performance issues and potentially crash the system.
- In case if you want to use current.update in before br then use current.setWorkflow(false).
2. Explain advantages of Asynch BR over After BR or vice versa.
Advantages of "Asynchronous" Business Rules:
- They run in the background, minimizing the impact on user experience.
- Suitable for time-consuming processes like data calculations, sending notifications, or integrations.
- Ideal for long-running tasks that don't require immediate user feedback.
Advantages of "After" Business Rules:
- They execute immediately after a record is saved, allowing for real-time actions.
- Useful for scenarios where you need to interact with the user interface, such as showing confirmation messages.
- Better for tasks that require immediate updates visible to the user.
3. Can we call a scheduled job from BR?
- No, you cannot directly call a scheduled job from a Business Rule. Scheduled jobs are independent processes managed by the ServiceNow scheduler. However, you can indirectly trigger a scheduled job by creating a condition in the Business Rule that inserts a record or changes a field that the scheduled job monitors. This way, the scheduled job will execute based on its configured schedule and conditions.
4. Did you ever call a script include in BR? Why do we call a script include in BR if we can write the same script in BR itself?
- Yes, it's common to call script includes in Business Rules. The main reasons are code reusability, maintainability, and modularity. Script includes allow you to centralize and reuse code across multiple Business Rules, scripts, and modules. This approach promotes consistency and reduces the risk of duplicating code. Additionally, script includes can be easily tested and updated independently, enhancing code management and troubleshooting capabilities. Writing the same script directly in a Business Rule may lead to code redundancy, making it harder to maintain and troubleshoot.
- Calling script include in br: var gr=new scriptinclidename().scriptincludefunctionname(any parameters you want to pass)
1. How do you debug BR? What are the different ways to debug BR?
- Debugging Business Rules can involve techniques like:
- Adding gs.log() statements to log messages to the system log.
- Setting breakpoints in the Business Rule.
- Using the "Script Debugger" tool to step through the script.
- Examining the system logs to trace the execution flow.
2. Explain any scenario where we can't use Asynch BR?
- You might avoid using an "Asynchronous" Business Rule when:
- Real-time user interaction is necessary immediately after record save.
- You need to show user feedback, such as pop-up messages, right after an action.
- The process requires immediate updates that should be visible to the user.
3. Explain any scenario where we can use Display BR instead of using GlideAjax?
- "Display" Business Rules are useful when:
- You want to dynamically show or hide fields, sections, or related lists on a form based on specific conditions without a server request.
- Display Business Rules execute their logic when a form loads and a record is loaded from the database. They must complete execution before control of the form is given to a user. The purpose of a display Business Rule is to populate an automatically instantiated object, g_scratchpad. The g_scratchpad object is passed from the display Business Rule to the client-side for use by client-side scripts. Recall that when scripting on the client-side, scripts only have access to fields and field values for fields on the form and not all of the fields from the database. Use the g_scratchpad object to pass data to the client-side without modifying the form. The g_scratchpad object has no default properties.
Type Use case Display Business Rule in ServiceNow:
Code written in display business rule get executed before the form is presented to the user and just after the data is read from the database.For e.g. you have written the code that when xyz user click on information box then only data related to that user specific country will get displayed to user. It means that user from US can see US specific data and user from India can see India specific data.
Before Business Rule in ServiceNow:
Code written in before business rule get executed when user submits the form and data is not saved in database.
Let’s say User click on submit button --> Before business rule code executes --> information will save in database.For e.g. Let’s say you have written the code that when user click on submit button then some extra information which in not filled by user such as user current location, user manager name and user past activities will get save when user click on submit button.
After Business Rule in ServiceNow:
Code written in after business rule get executed when user submits the form and data saved in database.
Let’s say User click on submit button --> data saved in database --> Now after business rule code get executed.For e.g. there is parent incident and child incident and you want that related child incident will get closed automatically after the parent incident get closed by user.
Async Business Rule in ServiceNow:
Async business rules are like after business rule but it runs in the background simultaneously with other processes. Means async business rule run after the data is saved into the database.
Running on background means that use can proceed with other functionality and code will run on the background which will not impact the user while doing other transitions.For e.g. Incident ticket is in pending customer action status and will be auto closed after 5 days if user did not provide any update on incident ticket.
display Use to provide client-side scripts access to server-side data. before Use 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. after Use to update information on related objects that need to be displayed immediately, such as GlideRecord queries. async Use to update information on related objects that do not need to be displayed immediately, such as calculating metrics and SLAs.
Please mark it as helpful if its works so it can benefit the community.
Thanks,
Abin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
thanks but your Q/A are easy i want tricky question that mostly interviewers may ask ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
It is better to learn the concepts and practice in PDI to understand various ways you can use the client-side and service-side scripting. Interview is a different process compared to your certification exam, in exams you are evaluated whether answer is correct or not but during interview you would be given a scenario on how you would design/implement a requirement or resolve an existing issue. You would need to explain how would you approach a new requirement or resolve a problem.
Interviewers would appreciate your knowledge and out of box thinking rather than looking for perfect answers, this is not a certification dump to prepare for exam. If interviewer is technically sound, they can easily understand whether you know the platform or not.
Go through below documentation, watch related YouTube videos and practice various scenarios in PDI
If you are not able to understand a concept or stuck somewhere, post in the community and you will get guidance from the experts.
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan