- 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 08:55 AM
If user's Company has country france: It should not hide (working only for admins and Users and not Contacts)
If user's Company has other country: It should hide (working only for admins and Users and not Contacts)
When both the above scenarios are tested by impersonating a Contact(end user), it doesn't hide in any of the scenario.
Also in the above reply, I've attached a screenshot which shows the roles of a Contact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2020 11:06 PM
Hi Hardik,
What is the meaning of Contacts?
In the script we are doing query to sys_user table?
Does your contact user have entry into that sys_user table?
Are those contact users stored in some other table and that table has country information?
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-10-2020 05:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2020 08:07 AM
Hi Hardik,
Ok so you have this table "customer_contact" which stores the user record as well.
You can then query this table if you require as below
Note: the company field on customer_contact refers to table "customer_account"
I was not able to find country field there
getCompany: function(){
var gr = new GlideRecord('customer_contact');
gr.get('user_name', gs.getUserName());
if(gr.company.country == 'France')
return 'true';
else
return 'false';
},
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-13-2020 04:07 AM
Hii Ankur,
I think the issue here is something else.
I'll create a new question for this issue.
Thanks.