subhashuniyal
Tera Contributor

Hi guys,

Recently I had a requirement to check in ACL if a record is being accessed in Service Portal or in the platform. I couldn't find any OOB function that does it, so wrote the below Script Include that does it using couple of functions that I got from the community and one of the OOB Script include. I hope this helps.

var servicePortalUtils = Class.create();
servicePortalUtils.prototype = {
initialize: function() {
},

isServicePortal:function(){

try{
if(GlideTransaction.get().getRequest()){//Putting a check else it was returning undefined for emails which does make sense
var referer = GlideTransaction.get().getRequest().getHeader("referer"); //courtesy : https://community.servicenow.com/community?id=community_question&sys_id=15804fe1db98dbc01dcaf3231f96192f
var isServicePortalURL = new GlideSPScriptable().isServicePortalURL(referer); // from the script include SPEntryPage
return isServicePortalURL;
}
return false;
}catch(e){
gs.info('Error in script include servicePortalUtils '+e);
}

},

type: 'servicePortalUtils'
};

Version history
Last update:
‎11-21-2018 03:25 PM
Updated by: