SNOW-CAD Automating application logic with business rules and scripts • Complete Question Bank
Complete SNOW-CAD Automating application logic with business rules and scripts question bank — all 0 questions with answers and detailed explanations.
Refer to the exhibit.
Business Rule: 'Set Category on Insert'
Table: [incident]
When to run: Before insert
Condition: true
Script:
(function executeRule(current, previous /*null when async*/) {
var cat = new GlideRecord('sys_choice');
cat.addQuery('name', 'incident');
cat.addQuery('element', 'category');
cat.addQuery('value', current.correlation_id.toString());
cat.query();
if (cat.next()) {
current.category = cat.value;
}
})(current, previous);Drag steps to the numbered slots on the right, or tap a step then tap a slot.
Drag a concept onto its matching description — or click a concept then click the description.
User-created custom table
System table (platform core)
Scoped application table
Performance Analytics tables
CMDB tables
function executeRule(current, previous, gs) {
if (current.category.changes() && current.category == 'hardware') {
current.assignment_group.setValue('hardware_group');
}
}2023-10-01 12:34:56 Error: Script error: Cannot read property 'sys_id' of null Script: Business Rule "Update Related Records" on Incident table Line: 15
var MyUtils = Class.create();
MyUtils.prototype = {
initialize: function() {},
getTotal: function(table, query) {
var ga = new GlideAggregate(table);
ga.addQuery(query);
ga.addAggregate('SUM', 'amount');
ga.query();
if (ga.next()) {
return ga.getAggregate('SUM', 'amount');
}
return 0;
},
type: 'MyUtils'
};Refer to the exhibit.
var gr = new GlideRecord('incident');
gr.addQuery('category', 'network');
gr.query();
while(gr.next()){
gr.setValue('state', 2);
gr.update();
}Refer to the exhibit.
Business Rule: 'Check State Change' on Incident table
Condition: current.state.changesTo('Resolved')
When: after
Script: (empty)Refer to the exhibit. Business rule on Incident table: Name: Set Assignment Group When: before Condition: current.caller_id.changes() || current.short_description.changes() Script: current.assignment_group = 'IT Support';
Business Rule: "Update CI on Incident Update"
Table: Incident
When: After update
Script:
(function executeRule(current, previous /*null when async*/) {
if (current.state.changesTo('Resolved')) {
var ci = current.cmdb_ci;
if (ci) {
var gr = new GlideRecord('cmdb_ci_server');
gr.get(ci);
gr.operational_status = 'In Use';
gr.update();
}
}
})(current, previous);In a large enterprise environment, the ServiceNow instance is heavily customized. A business rule on the Change Request [change_request] table runs on after update to initiate a complex workflow involving multiple approvals and updates to Configuration Items (CIs). Recently, the IT operations team noticed that the workflow fails to start for many change requests. The system logs show the error: "Business rule script error: Cannot read property 'sys_id' of null". The developer inspects the business rule script and sees the following code snippet:
var task = new GlideRecord('task');task.get(current.sys_id);
var relatedCI = task.cmdb_ci;
// The rest of the script uses relatedCI to update the CI's status. The developer knows that change requests are not stored in the task table; they are in change_request. However, the script was written by a previous developer and has been working for months. The developer must fix the script to ensure the workflow starts correctly. Which action should the developer take?
A mid-sized company heavily relies on ServiceNow for incident management. They have a business rule that runs before insert on the Incident table. The rule dynamically sets the assignment group based on the category of the incident and the location of the caller. To determine the correct group, the script performs a GlideRecord query against a custom table called "u_group_mapping", which contains approximately 5000 records mapping category-location pairs to groups. During peak business hours, when many incidents are created simultaneously, the business rule causes significant delays and occasional timeouts, impacting user experience. The development team has been tasked with optimizing this business rule without changing its functionality. The current script structure is roughly: (function executeRule(current, previous) {
var gr = new GlideRecord('u_group_mapping');gr.addQuery('category', current.category); gr.addQuery('location', current.caller_id.location); gr.query();
if (gr.next()) {current.assignment_group = gr.assignment_group;
} })(current, previous);
The team wants to reduce the database access overhead. Which optimization technique should the developer implement?
A ServiceNow instance has a business rule named 'Update CI Status' that runs on the 'Change Request' table after insert. The rule is intended to update the 'Configuration Item' record's 'Operational Status' to 'Under Maintenance' when a change request is created. The business rule uses the following script:
(function executeRule(current, previous != null)) {
var gr = new GlideRecord('cmdb_ci');gr.get(current.cmdb_ci); gr.operational_status = 'Under Maintenance'; gr.update();
})(current, previous);
After a recent upgrade to the Vancouver release, the business rule stopped working. The change request is created successfully, but the CI's operational status remains unchanged. The system logs show no errors. What is the most likely cause and the correct fix?
A. The business rule is running asynchronously; change it to synchronous. B. The condition field is empty; add 'gs.action() === 'insert'' as the condition. C. The 'current.cmdb_ci' field is not populated; check that the field is required on the form. D. The script uses 'previous' incorrectly; remove 'previous != null' from the function signature.
A senior developer has created a complex business rule called 'Asset Assignment' on the 'alm_asset' table that runs after insert. The rule queries the 'User' table to find a manager and assigns the asset to that manager's department via a GlideRecord update. The rule has an order of 100. Another business rule called 'Asset Log' on the same table also runs after insert with an order of 200, which logs the assignment in a separate table. After deploying to production, the 'Asset Log' rule executes but the assignment update from 'Asset Assignment' fails silently. The developer discovers that the 'Asset Assignment' rule has a condition script that references a new field that was not added to the 'alm_asset' table in production. The field exists in the developer's instance but not in production. The developer wants to minimize disruption and fix the issue quickly. Which action should the developer take?
A. Change the condition script to check if the field exists before using it, and if not, exit the script gracefully. B. Reorder the business rules so that 'Asset Log' runs first and 'Asset Assignment' runs second, and add a condition to 'Asset Log' to only run if the assignment succeeded. C. Remove the condition from 'Asset Assignment' and move the field existence check into the script, setting the field value only if it exists. D. Deactivate the 'Asset Assignment' business rule until the field is added to the table in production, then reactivate it after the next maintenance window.
Refer to the exhibit.
var gr = new GlideRecord('incident');
gr.get('681ccaf9c0a8016400bf7952c6d0a7ef');
gr.setValue('short_description', 'Test update');
gr.update();