Can we use JSUtil in scoped application..?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 04:19 AM
Can i use !JSUtil.nil in the script instead of (current.u_vendors == '')
Below is the UI action which is for a scoped application, if yes how? Please help with the script changes.
function promptForPromoteMIC() {
if (!g_form.getControl('work_notes')) {
getMessage('Cannot promote major incident candidate as "Worknotes" is not visible', function(msg) {
g_form.addErrorMessage(msg);
});
return false;
}
var dialog = new GlideModal('sn_major_inc_mgmt_mim_workbench_promote', false, 848, 350);
getMessage('Promote to Major Incident', function(msg) {
dialog.setTitle(msg);
});
ScriptLoader.getScripts('/scripts/incident/glide_modal_accessibility.js', function() {
dialog.template = glideModalTemplate;
dialog.on('bodyrendered', function(event) {
glideModalKeyDownHandler(event, dialog.getID());
});
dialog.setPreference('WORK_NOTES', g_form.getValue('work_notes'));
dialog.setPreference('BUSINESS_IMPACT', g_form.getValue('business_impact'));
dialog.setPreference("focusTrap", true);
dialog.render();
});
}
if (typeof window == 'undefined')
promoteMIC();
function promoteMIC() {
var arr = [];
var contact = "Manulife Internal";
var vList = current.u_vendors.toString();
var venList = vList.split(",");
if (venList > 0) {
arr = current.u_vendors.split(',');
} else
current.u_vendors = current.u_vendors; //(I have been advised to use !JSUtil.nil instead of (current.u_vendors == '')
var arrayUtil = new global.ArrayUtil();
if (!arrayUtil.contains(arr, contact)) {
arr.push(contact);
}
current.u_vendors = arr.join();
var mim = new sn_major_inc_mgmt.MajorIncidentTriggerRules(current);
mim.approveMIC();
action.setRedirectURL(current);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 04:24 AM
Hi,
yes JSUtil is available to non-global scopes. You'll need to prefix your call with the global namespace identifier.
global.JSUtil.nil(current.u_vendor).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 04:36 AM
Hi,
It should work as per what Kieran has mentioned by using the global quantifier
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2021 11:33 PM
Hope you are doing good.
Did my reply answer your question?
If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.
If not, please let us know if you need some more assistance.
Thanks!
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader