Glide Ajax is returning null value in UI script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 07:45 AM
Hello Guys,
i am calling script include from UI script , but i am getting null response ( alert line 10) , if you may say that issue in Script include but i have tested same si in on load script and it gave my response but UI script its giving null
UI Script :

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 07:53 AM
@Deepak89 Can you update the UI Script as follows.
addLoadEvent(function() {
var url = document.URL;
var company = new GlideAjax('SOG_UserCompany');
company.addParam('sysparm_name', 'getComp');
company.addParam('sysparm_user', g_user.userName );
company.getXMLWait();
var x = company.getAnswer();
//alert(x);
if (g_user.hasRoleExactly('snc_external', true) && !g_user.hasRoleFromList('snc_internal, admin', true) && document.URL.indexOf('.do') != -1) {
var mfaUrl1 = '/multi_factor_auth_setup_page.do';
var mfaUrl2 = '/validate_multifactor_auth_code.do';
var mfaUr13 = 'assessment_take2.do';
if (url.indexOf(mfaUrl1) > 0 || url.indexOf(mfaUrl2) > 0 || url.indexOf(mfaUr13) > 0) {
//ignore expections
return;
}
window.location = x;
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 08:05 AM
Hello Sandeep,
Giving null .
is it bcoz i have use g_user.userName but i can not able to find to find how can i get logged user details
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 08:15 AM
Also let me add i am impersonating as end user which is portal page and then try opening backend URL (like incident.list ) , i am trying to redirect user to based on output from SI , but its redirecting to null suffix at end but i want to set it based on output from SI where am sending suffix and then setting window.location = return sufix from SI

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 08:34 AM
@Deepak89 You are fetching userName in UIScript and in script include the glide record is checking with sys_id. Update the script as follows.
addLoadEvent(function() {
var url = document.URL;
var company = new GlideAjax('SOG_UserCompany');
company.addParam('sysparm_name', 'getComp');
company.addParam('sysparm_user', g_user.userID );
company.getXMLWait();
var x = company.getAnswer();
alert(x);
if (g_user.hasRoleExactly('snc_external', true) && !g_user.hasRoleFromList('snc_internal, admin', true) && document.URL.indexOf('.do') != -1) {
var mfaUrl1 = '/multi_factor_auth_setup_page.do';
var mfaUrl2 = '/validate_multifactor_auth_code.do';
var mfaUr13 = 'assessment_take2.do';
if (url.indexOf(mfaUrl1) > 0 || url.indexOf(mfaUrl2) > 0 || url.indexOf(mfaUr13) > 0) {
//ignore expections
return;
}
window.location = x;
}
});