- 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-07-2020 04:12 AM
Hi,
You can do this with onChange catalog client script where you need to get the value of logged in user's company and check if it contains 'France' then make use of g_form.setVisible('variable name',false) to hide variable.
Thanks,
Pooja M
- 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-07-2020 05:05 AM
Thanks Ankur.
That worked.
Just a small question ... will this work if the field to be hidden is Mandatory??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2020 09:10 AM
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader