Skip to content

Commit 3bd08fd

Browse files
aman2519adminniamccash
authored
Setvallue display parameter (#90)
* Added scan check for Running Business rules for transform map * Scan check for "Use GlideRecordSecure instead of GlideRecord API for CCSI" * Adding linter scan check for setValue display parameter * Update README.md * Updated scan check --------- Co-authored-by: admin <admin@example.com> Co-authored-by: niamccash <39105458+niamccash@users.noreply.github.com>
1 parent 4a9b06c commit 3bd08fd

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ api.controller = function ($rootScope, $scope) {
185185
### Provide alternate value when fetching Glide property
186186
Recommendation to provide alternate/default value when calling gs.getProperty() to avoid errors if the property is not set.
187187

188+
### Using setValue()'s displayValue Parameter with Reference Fields
189+
When using setValue() on a reference field, be sure to include the display value with the value (sys_id). If you set the value without the display value, ServiceNow does a synchronous Ajax call to retrieve the display value for the record you specified. This extra round trip to the server can leave you at risk of performance issues.
190+
188191
### Running Business Rules on Transform Maps
189192
Running business rules during transform may cause the transform to take longer than expected, or cause the instance to slow down.Do not run items like business rules, workflows, approval engines, and so on during a transform unless you want all insert and update business rules, notifications, and workflows to run
190193

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
r4ZuX_Pi1kiBWA3uccoq6uRBy5jhyU7u2FWxZb2f3Ljn3XhaKUHx5gmeOg0xXarKLDSSUuu2ohefZAzWNoWneSzxr5Y4vQT1Env7MeNsLl0kj_G8SpHUwUVoPxt7fILrxdvRFHO53wQ1lrXgE50HG7sazqh9s1KgUEMYAyXLNktTH1J9tNg5V-7sL-I4U4ZUB4NfOLMYsNopUnApMA5Tup2Eh66FQ4srJDTBM_3rDMHtqLXBhnFjAPXcEr4h7Z6q3_dbloqAuiP7Lvq2IksKp0-cWND3Inh_g58QP3yhkhxngsNT0mV6b4Sf1-l3QR7JGbG8-S-KezXbuJab5rPdOPu7mJNzR6A8K0QzYu8FWPQtGkvvH-gmniqKk6NV4-RAR_x1pxdZSGPTXz3vLvk_HhS0kY9BMHpTeOcpoub9YNzc8m4yjtte8G7ceciXRN-5bRzwTyqkgKJB7JEn6D4SRFFOqDCmkYTWv3PZUp_sznMQ76nSassjdoCNCUW1o1XVUmmp3XiMp5bnefYAyfaEBTYkQkVNiLUZ3S3G6VF4uXq54PK26Nrj9NHwiv7dIYn3xPkU7BlHHFZpthr-zMDLejkwV89iGv_bqhn0F3uKnv4a_CJhXa5U4rfWQIwiDo27aheYcsNvqhQ6Sbb4wC2OYXTbdY7JsGUmpDiimevQ6nk
1+
EwzwYi9oGVvBPFVVP4VvTH8iqkJk6zG-ugt1IQoWzimJwfCK41JFgpYBAyaYT9WYBgBmwJnQIukNiq2zOdAxDHmJun9N0Mpe6Q9Lp0vaj_pCeUgq2-o_QQLrSsmGtE-v7jCix_Je-lRKCEXfm_qaFmVsuZ_cCorZXg_Jh3Y8MQyxzRe_FSPPYBoORzY15gkeKONfUpUHG1secSFdVx5guLGl8khrY9sxTVpJlby1TzM5jA9HbeTqjVst4cv8OrbSppCCjRT7fdORqksNN_f4AbOW5UlGFQC4NnWuhGbOb6Wh5Jbuf2mAc3889aXO__tXaxarYujlHR-JAYnvFEtJB_W3kyfy1E6l-wvjPFPi0HD3jEA0YaHXUlypJ-U0EPfIs_W6zWnypB5ODwQ3ntGOr8eBbbNuqySIrJNCsciq5n8gT31eL71q_MDX6boGnIoOxDpwuSX7qr1AeQdW1H4X-7m1oVbnyPhzDLgbCL2kkXcoVhhZ4YjQ8JkcXNf81FekS1P-jmpZZmFPmixFUrNHbGWt3M28LRdxmk1MM_av-Dc94sH7Ic6tmcZwNScfjbVhzCHH3wI6DH8ewsC2ZTYQ17BaT4pNwPNTiMBGHHszEYIWy41DIoe-tLfgPyf8woq5LrQrkqLck3EVrvP6EXX12x0iop0F9V1J2KIY0SuEKFk
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_linter_check">
2+
<scan_linter_check action="INSERT_OR_UPDATE">
3+
<active>true</active>
4+
<category>performance</category>
5+
<description>When using setValue() on a reference field, be sure to include the display value with the value (sys_id). If you set the value without the display value, ServiceNow does a synchronous Ajax call to retrieve the display value for the record you specified. This extra round trip to the server can leave you at risk of performance issues.</description>
6+
<documentation_url>https://developer.servicenow.com/dev.do#!/guides/tokyo/now-platform/tpb-guide/client_scripting_technical_best_practices</documentation_url>
7+
<finding_type>scan_finding</finding_type>
8+
<name>Using setValue()'s displayValue Parameter with Reference Fields</name>
9+
<priority>3</priority>
10+
<resolution_details>Using the third parameter, where display name of the reference record can be passed.</resolution_details>
11+
<run_condition/>
12+
<score_max>100</score_max>
13+
<score_min>0</score_min>
14+
<score_scale>1</score_scale>
15+
<script><![CDATA[(function(engine) {
16+
17+
engine.rootNode.visit(function(node) {
18+
if (node.getTypeName() === "STRING") {
19+
var text = node.toSource();
20+
21+
// looks for all occurrences of g_form.setvalue() and verifies it has all the relevant
22+
// paramters, which includes display name to avoid the synchronous ajax call
23+
var pattern = /g_form\.setValue\(([^,]*),([^,]*)\)/gm;
24+
var regExp = new RegExp(pattern);
25+
var matchFound = regExp.test(text);
26+
if (matchFound){
27+
engine.finding.incrementWithNode(node);
28+
}
29+
}
30+
});
31+
32+
})(engine);]]></script>
33+
<short_description>Using setValue()'s displayValue Parameter with Reference Fields</short_description>
34+
<sys_class_name>scan_linter_check</sys_class_name>
35+
<sys_created_by>admin</sys_created_by>
36+
<sys_created_on>2023-10-13 13:18:39</sys_created_on>
37+
<sys_id>85c352ae2f3db11002eb2ca62799b68e</sys_id>
38+
<sys_mod_count>2</sys_mod_count>
39+
<sys_name>Using setValue()'s displayValue Parameter with Reference Fields</sys_name>
40+
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
41+
<sys_policy/>
42+
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
43+
<sys_update_name>scan_linter_check_85c352ae2f3db11002eb2ca62799b68e</sys_update_name>
44+
<sys_updated_by>admin</sys_updated_by>
45+
<sys_updated_on>2023-10-13 14:49:20</sys_updated_on>
46+
</scan_linter_check>
47+
</record_update>

0 commit comments

Comments
 (0)