- 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 07:23 AM
Hi Asha,
The script itself is within the Global scope.
I added the logging as gs.log and found the following:
If I call within gs.print from a background script it evaluates correctly and updates the log
If I run the menu link as javascript:getUserPortal(); Nothing happens, the log doesn't update;
If I run the menu link as:
/core_company_list.do?sysparm_offset=&sysparm_list_mode=grid&sysparm_query=u_end_user_portalLIKEjavascript:getUserPortal();
It evaluates and updates the query but does not update the log.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 07:45 AM
I simplified my code just to make it cleaner but still no dice when using the menu just to call javascript:getUserPortal();
I tried calling it like the debug modules do as well, and still nothing javascript:window.top.getUserPortal(); and javascript:window.open(getUserPortal());
function getUserPortal() {
var company = gs.getUser().getCompanyRecord();
var endUserPortal = company.u_end_user_portal;
var portalSuffix = endUserPortal.url_suffix;
if (company) {
var portal = portalSuffix;
portal = (portalSuffix) ? '/' + portal + '?sysparm_stack=no' : '/esp?sysparm_stack=no';
return portal;
} else {
return '/esp?sysparm_stack=no';
}
}
