Skip to content

Commit c17ab54

Browse files
snamjoshadminLacah
authored
Created a new instance scan check for client scripts (#147)
* Commited a new instance scan check for verifying isLoading Check in client scripts. * Updated README.md to include new instance scan check --------- Co-authored-by: admin <[email protected]> Co-authored-by: Laszlo <[email protected]>
1 parent ed3e217 commit c17ab54

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@ In your JDBC data load configuration, ensure that the 'last run datetime' option
348348
### Use of setWorkflow(false) in business rules will cause unexpected issues
349349
As setWorkflow(false) method will stop the execution of business rules on that particular GlideRecord object, this will result in unexpected behaviour where the execution of business rules skipped. Maintain caution while using this method and perform regression testing to avoid possible risk. It can have noticeable impact on Audit, Journal fields, notifications, SLA engine, workflow, flow engine etc.,
350350

351+
### Make use of isLoading Check (onChange Client Scripts Only)
352+
353+
The isLoading flag is the simplest way to prevent unnecessary code from taking up browser time. The isLoading flag should be used at the beginning of any script which is not required to run when the form is loading. There is no need to run this script on a form load because the logic would have already run when the field was last changed
354+
355+
351356
# Additional resources
352357

353358
Please check these additional links for more information and details:
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FFSb285LVQLVwwSy1sN9TSS_xgKMdxMueRetT0HDGeIrQsCSVVqvJzq4M3L_pFYItVzRNDhnJyUVmYX7kiDXTToGUlLA1bTP6qfEDtDOKAjH87dpFAYY0oCn-BigJNe6f5mwNAGVBXr3LuZsGmtUK_ximdlxUEYd2DZxoRROrqzIDgwXIAvh0-j8KEYoBGFnBral4LH5FhuzlJImUAh098OvSvclL5NbEYBf4VBqcQZvIP0u2vboUXo2rJ16Kn3iNtzuxPYimD5mfRTRkV7zFDIUxiwGXxf7ncKbO3VZh7DcKeHkGN1Y1RSR1Q_3KyIwoW0YLyKn22G80MIiVx__BKyrof0MY632nGIwHhAstzV83wEoStOilvUdjSJKPNxx9aAft3baZjboj6P8La47D0rfw5lgqOIHq1TnThxjiAlBctfD78qPrva7lfQmipEPZuFHfrKqJ32T_MbAug2xxmt22tnbKCDBDfw8MUc5v3nprsHYFFewiMuZflFHhISDzjSPs2TIy60TrSISouTfVY-p4IgG_v-eSXage9wzpvjoHQZnMwvZrePEtW62OkG8TmD86uZtWTHlPYo2Prj1OGaXZRGHvd3K4bbdtwOWKq9exXozy83yl_w_U3ich8kLj1LuppKxCmMQVEnPvUSdxqwtkqGidBLqZKTcVLCFqJc
1+
WxlZrk3tCfYVHk_P7E55adKaUW_gqoyy24ppXoe_69vo--9SyJclWjdUy5AQkY5Ap_mxCkrx2gvrGWKEztSmdYjsA4ae2kZovmnl1WpoJUNyffVi867QMODK6SMwn0UNtdRC8gTv1FbwX3v-kAwkwRrMVqITUc0oqJp3zLDHmyYoQM2T6qV-EG4KiSlwyRmP3dlRKdSG6hawJEEI99CCJvY-wukSHzmbPQfH_G8V9yze8DiZjeTqDdJLWYPG35QHA2HBDB1FBoZEWSv9uhCuYKQKyFa-2NK_8Lqa55PApoY6LgwN6iPEY8s4JyUnCO8D0Fghg8o73gjuITnNh9IUu-YLqeEqJ0CTkwot5zocpLIQv-6fxsYmKdhxsxVi_Mq-iK36MqsjC14OJ343BcC8-HmTWhN53mgYYiaemNVl2kfKgi2CwvDLruj-aalscIT1lsxEDt0Eg7OCfEvLo-VnqO2Fhyn1pczEzV06naJgmeeKBJOVOqW2TGe2bHELdkgHlorijjTcgzZqlWRtWTrrsS46nrNrUPOD4Vd456NflTNsyXSuWBPr2thZ4aM77UKfrzWoWpgbCYq8QPt3MTp907h91ovrgQqpqdLWW2M9e8DxQ6iZUv-7r-Aw8uvIMkFSAJvV1UiYZ3nGZiqjxjH6bKTZjRuQ-2MEEy0eeAPEbeY
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_table_check">
2+
<scan_table_check action="INSERT_OR_UPDATE">
3+
<active>true</active>
4+
<advanced>false</advanced>
5+
<category>upgradability</category>
6+
<conditions table="sys_script_client">type=onChange^scriptNOT LIKEisLoading^EQ<item display_value="onChange" endquery="false" field="type" goto="false" newquery="false" operator="=" or="false" value="onChange"/>
7+
<item endquery="false" field="script" goto="false" newquery="false" operator="NOT LIKE" or="false" value="isLoading"/>
8+
<item endquery="true" field="" goto="false" newquery="false" operator="=" or="false" value=""/>
9+
</conditions>
10+
<description>The isLoading flag is the simplest way to prevent unnecessary code from taking up browser time. The isLoading flag should be used at the beginning of any script which is not required to run when the form is loading. There is no need to run this script on a form load because the logic would have already run when the field was last changed. </description>
11+
<documentation_url>https://developer.servicenow.com/dev.do#!/guides/xanadu/now-platform/tpb-guide/client_scripting_technical_best_practices</documentation_url>
12+
<finding_type>scan_finding</finding_type>
13+
<name>isLoading Check (onChange Client Scripts)</name>
14+
<priority>1</priority>
15+
<resolution_details>e.g //Set Assignment Group to CI's support group if assignment group is empty&#13;
16+
function onChange(control, oldValue, newValue, isLoading, isTemplate) {&#13;
17+
&#13;
18+
if (isLoading)&#13;
19+
return;&#13;
20+
&#13;
21+
var ga = new GlideAjax('ciCheck');&#13;
22+
&#13;
23+
ga.addParam('sysparm_name', 'getSupportGroup');&#13;
24+
ga.addParam('sysparm_ci', g_form.getValue('cmdb_ci'));&#13;
25+
ga.getXML(setAssignmentGroup);&#13;
26+
}&#13;
27+
&#13;
28+
function setAssignmentGroup(response) {&#13;
29+
&#13;
30+
var answer = response.responseXML.documentElement.getAttribute("answer");&#13;
31+
&#13;
32+
g_form.setValue('assignment_group', answer);&#13;
33+
}</resolution_details>
34+
<run_condition/>
35+
<score_max>100</score_max>
36+
<score_min>0</score_min>
37+
<score_scale>1</score_scale>
38+
<script><![CDATA[(function (engine) {
39+
40+
// Add your code here
41+
42+
})(engine);]]></script>
43+
<short_description>Keep the isLoading Check for onchange client script</short_description>
44+
<sys_class_name>scan_table_check</sys_class_name>
45+
<sys_created_by>admin</sys_created_by>
46+
<sys_created_on>2024-10-18 22:11:14</sys_created_on>
47+
<sys_id>a6f17e0e47d156109c6152e1d16d43d5</sys_id>
48+
<sys_mod_count>0</sys_mod_count>
49+
<sys_name>isLoading Check (onChange Client Scripts)</sys_name>
50+
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
51+
<sys_policy/>
52+
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
53+
<sys_update_name>scan_table_check_a6f17e0e47d156109c6152e1d16d43d5</sys_update_name>
54+
<sys_updated_by>admin</sys_updated_by>
55+
<sys_updated_on>2024-10-18 22:11:14</sys_updated_on>
56+
<table>sys_script_client</table>
57+
<use_manifest>false</use_manifest>
58+
</scan_table_check>
59+
<sys_translated_text action="delete_multiple" query="documentkey=a6f17e0e47d156109c6152e1d16d43d5"/>
60+
</record_update>

0 commit comments

Comments
 (0)