- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 06:10 AM
Morning All,
So I've created a script include to look up a users end user portal from their company (custom field):
function getUserPortal() {
var company = gs.getUser().getCompanyID();
var portalSuffix = new GlideRecord('core_company');
portalSuffix.get(company);
if (company) {
var portal = portalSuffix.u_end_user_portal.url_suffix;
portal = (portalSuffix.u_end_user_portal.url_suffix) ? '/' + portal + '?sysparm_stack=no' : '/esp?sysparm_stack=no';
return portal;
} else {
return '/esp?sysparm_stack=no';
}
}
I am then calling this in a URL from Arguments as:
javascript:getUserPortal();
However all that ever loads is a new blank tab, I've tried with client callable enabled and disabled. I've reviewed the other app modules using javascript but just can't seem to get this to work. I verified in a background script the correct URL is being returned.
Any suggestions appreciated, Thank you.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 09:17 AM
Hi,
You can try using processor to redirect url based on scripted logic.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 06:33 AM
Hi Simon,
If your script include is in scope please check if the script include is available for all scope.
Regards,
Monika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 06:55 AM
Morning Monika,
The script is in the Global scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 06:43 AM
Hi,
1) Is script include in global scope?
2) Can you put logs in script to see if url is getting returned from script include?
function getUserPortal() {
var company = gs.getUser().getCompanyID();
var portalSuffix = new GlideRecord('core_company');
portalSuffix.get(company);
if (company)
{
var portal = portalSuffix.u_end_user_portal.url_suffix;
portal = (portalSuffix.u_end_user_portal.url_suffix) ? '/' + portal + '?sysparm_stack=no' : '/esp?sysparm_stack=no';
gs.info("Portal URL [if statement]::"+portal);
return portal; }
else {
gs.info("Portal URL [else statement]::"+portal);
return '/esp?sysparm_stack=no';
}
}
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 06:54 AM
Morning Asha,
The script is in Global scope.
I added logging to gs.log.
When I call from a background script the log updates.
When I click the menu option I get no logging and nothing happens.
However I updated the URL with arguments to be:
/core_company_list.do?sysparm_offset=&sysparm_list_mode=grid&sysparm_query=u_end_user_portalLIKEjavascript:getUserPortal();
and it evaluated, however there was nothing in the log.