logo

NJP

Check in server script(Business Rules, ACL, Script Include,etc.) if a record is being accessed in Service portal or in platform

Import · Nov 21, 2018 · article

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'

};

View original source

https://www.servicenow.com/community/now-platform-articles/check-in-server-script-business-rules-acl-script-include-etc-if/ta-p/2297192