Redirect Via UI Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 04:21 AM
Under Service Portal->Theme -> JS Include -> UI Script I added the below script to redirect.
The redirect is working but the if condition (to check role and field value) are not working.
(function() {
var role = gs.hasRole("snc_internal");
var user = gs.getUser();
var userGr = user.getRecord();
if (role && (userGr.getValue("u_user_type") == "Guest") && (!userGr.getValue("u_org_id"))) {
var url = "https:test/supplier?id=kb_article_view&sysparm_article=KB0034151";
window.location.assign(url);
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 04:41 AM - edited 09-11-2024 04:41 AM
tried this one also
(function() {
function checkUserRole() {
var ga = new GlideAjax('UserRoleCheck');
ga.addParam('sysparm_name', 'checkUserRole');
ga.addParam('sysparm_role', 'snc_internal');
ga.getXMLAnswer(function(response) {
if (response === 'true') {
var url = 'https://supplierportal.asda.uk/supplier?id=kb_article_view&sysparm_article=KB0034151';
window.location.assign(url);
}
});
}
// Run the function when the script loads
checkUserRole();
})();
SCRIPT INclude