- 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:04 AM
Hi Simon,
Are you saying it is working now as expected?
If you don't see any log, it means it is breaking before those statements or function is not getting called at all.
May be put log at the 1 line in that function just to check if function is getting called or not.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 07:25 AM
Asha,
No unfortunately it is not. When I run it as intended just as "javascript:getUserPortal();"
It does not load anything. Yet works perfectly when I evaluate as a background script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 07:43 AM
I simplified my code just to make it cleaner but still no dice when using the menu just to call "javascript: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';
}
}
- 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 11:21 AM
You know one of those moments you feel really stupid.. this is one of those.
Thank you, I've used processors a bunch so I don't know why I didn't think of that.
