- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 04:10 AM
Access to api 'put(sys_user_preference.value)' from scope 'sn_hr_sp' has been refused due to the api's cross-scope access policy
How to fix this error.
In Header widget I used the below lines
Server Side -
var myreturn = false;
var prefVal = gs.getUser().getPreference("portal.first.login");
if (prefVal === null) {
// var currentTime = new GlideDateTime();
// gs.getUser().setPreference("portal.first.login", currentTime);
var grPref = new GlideRecord("sys_user_preference");
grPref.initialize();
grPref.name = "portal.first.login";
grPref.value = new GlideDateTime();
grPref.insert();
myreturn = true;
}
gs.info("Value in myreturn"+myreturn);
data.myval=myreturn;
Client Controller -
if(c.data.myval)
{
$location.url("/esc?id=hri_user_profile&sys_id="+$scope.userID);
}
Any idea to prevent this error.
Solved! Go to Solution.
- Labels:
-
Employee Service Center
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 12:41 PM
Got cross scope errors while using the Gliderecord for sys_user_preference in ESC Header widget. So I used Script Include and got value in service script of widget and redirected it further based on condition.
Client Callable Script Include
var spPortalCall = Class.create();
spPortalCall.prototype = Object.extendsObject(AbstractAjaxProcessor, {
type: 'spPortalCall',
isFirstTime:function(){
var isNew = false;
var prefVal = gs.getUser().getPreference("portal.new.login");
if (prefVal === null) {
isNew = true;
gs.getUser().setPreference("portal.new.login", new GlideDateTime());
}
return isNew;
}
});
In Header Widget - Client script added the below lines
if (c.data.value) {
location.href= "/esc?id=hri_user_profile&sys_id=" + $scope.userID;
//alert("Location is "+ location.href);
// $location.url("/esc?id=hri_user_profile&sys_id=" + $scope.userID);
}
In Header Widget - Server script added the below lines
data.value = new global.spPortalCall().isFirstTime();
gs.info("my data value --------" + data.value);
Thanks!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 08:07 AM
Hi,
What is the type of Tracking on this application for HR Service Portal?
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 05:53 AM
Hi Priyanga,
in case you log a case with ServiceNow to get the answer please share it here as well.
Thanks!
C.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 07:51 AM
Check the Restricted Caller Access module also to see if there's a record there for the access request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 12:41 PM
Got cross scope errors while using the Gliderecord for sys_user_preference in ESC Header widget. So I used Script Include and got value in service script of widget and redirected it further based on condition.
Client Callable Script Include
var spPortalCall = Class.create();
spPortalCall.prototype = Object.extendsObject(AbstractAjaxProcessor, {
type: 'spPortalCall',
isFirstTime:function(){
var isNew = false;
var prefVal = gs.getUser().getPreference("portal.new.login");
if (prefVal === null) {
isNew = true;
gs.getUser().setPreference("portal.new.login", new GlideDateTime());
}
return isNew;
}
});
In Header Widget - Client script added the below lines
if (c.data.value) {
location.href= "/esc?id=hri_user_profile&sys_id=" + $scope.userID;
//alert("Location is "+ location.href);
// $location.url("/esc?id=hri_user_profile&sys_id=" + $scope.userID);
}
In Header Widget - Server script added the below lines
data.value = new global.spPortalCall().isFirstTime();
gs.info("my data value --------" + data.value);
Thanks!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 02:06 AM
KB Article explaining this issue: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0788878