Skip to content

Commit 31c4639

Browse files
authored
HealthScan Finding : Prevent insert update operation in before BRs (#2150)
* Create test.js * Delete Specialized Areas/Fix scripts/test.js * Create script.js * Create README.md
1 parent 34494f1 commit 31c4639

File tree

2 files changed

+26
-0
lines changed
  • Client-Side Components/Client Scripts/Health Scan Prevent Insert Update in Before BRs

2 files changed

+26
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
**Client script Deatils**
2+
1. Table: sys_script
3+
2. Type: onSubmit
4+
3. UI Type: Desktop
5+
6+
**Benefits**
7+
1. This client script will prevent admin users to do insert/update operation in onBefore business rules.
8+
2. It will help to avoid HealthScan findings thus increasing healthscan score.
9+
3. Will prevent recursive calls.
10+
11+
Link to ServiceNow Business Rules best Practise : https://developer.servicenow.com/dev.do#!/guide/orlando/now-platform/tpb-guide/business_rules_technical_best_practices
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function onSubmit() {
2+
/*
3+
This client script will prevent insert and update operation in onBefore business rules.
4+
Table: sys_script
5+
Type: onSubmit
6+
Ui Type: Desktop
7+
*/
8+
var whenCond = g_form.getValue('when'); // when condition of business rule
9+
var scriptVal = g_form.getValue('script'); // script value of business rule.
10+
11+
if (whenCond == 'before' && (scriptVal.indexOf('insert()') > -1 || scriptVal.indexOf('update()')) > -1) {
12+
alert("As per ServiceNow best Practise insert and update should be avoided in onBefore BRs. If you still want tp proceed try deactivating client script : " + g_form.getUniqueValue());
13+
return false;
14+
}
15+
}

0 commit comments

Comments
 (0)