- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2020 04:05 AM
Hello All,
I have a requirement where on a Catalog item for table 'sn_customerservice_case', there is a variable "u_regression" which needs to be hidden if the logged in user/contact's company has a country "France". (User > Company > Country).
I tried creating a Catalog ui policy but wasn't able to create exact condition.
What would be the right approach here?
Please help.
Thanks.
Solved! Go to Solution.
- Labels:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2020 04:22 AM
Hi Hardik,
you can use onload client script for this and glideAjax combination
Client Script:
function onLoad() {
// show by default
g_form.setVisible('u_regression', true);
//Type appropriate comment here, and begin script below
var ajax = new GlideAjax('getCompanyUser');
ajax.addParam('sysparm_name', 'getCompany');
ajax.getXML(callBackMethod);
}
function callBackMethod(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer == 'true'){
g_form.setVisible('u_regression', false); // hide if france
}
}
Script Include: It should be client callable
var getCompanyUser = Class.create();
getCompanyUser.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCompany: function(){
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
if(gr.company.country == 'France')
return 'true';
else
return 'false';
},
type: 'getCompanyUser'
});
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2020 01:15 AM
I tried the method that you gave .... it works well in my personal instance.
But when i tried it on another instance it is not working.
Can you please check and tell me if anything is wrong in the below configuration??
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2020 05:10 AM
Hello Ankur
The script works very well for admins and Users but it doesn't work for end users (contacts)
I already have an ACL on the field u_regression and also the roles for contacts are:
Can you help me on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2020 05:22 AM
Hi Hardik,
As per the script we are not querying any table etc
So ideally that should not be an issue
Image is broken. Can you add it again?
Also why ACL is required on the variable "u_regression". It's a variable.
Did you check adding alert what the value you get for answer?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2020 06:27 AM
Hello Ankur.
I'm getting same alert values for both, France contacts as well as normal contacts.
But for admins and Users, I'm getting different alert values.
So the problem is only for Contacts.
Also u_regression is used in Catalog item that is linked in ServicePortal for contacts.
Please help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2020 08:22 AM
Hi Hardik,
Here ACL should not come into picture.
Ok so lets try step by step
1) if user has country as France what happens
a) it should hide -> is this working fine?
2) if user country is not France what happens
a) it should not hide -> is this working fine?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader