- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 02:49 AM
Need to display field based on custom flag which is created in user table. I tried ACL it working, is there anyway to hide the field based on flag
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 03:19 AM
Hi @deepika adimu,
Using Glide Record in Client script is not best practice, Try to use client callable script include to display the field
Script Include :
var TestingScript = Class.create();
TestingScript .prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkFlag: function(){
var sysID = this.getParameter('sysparm_uniqueNum');
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',sysID);
user.query();
if(user.next()){
return user.u_custom_field;
}
},
type: 'TestingScript '
});
and call this script include in On Load Client script to hide the field based on the flag
function onLoad() {
var ga = new GlideAjax('TestingScript ');
ga.addParam('sysparm_name','checkFlag');
ga.addParam('sysparm_uniqueNum',g_user.userID);
ga.getXML(callBack);
function callBack(response){
var answer = response.responseXML.documentElement.getAttribute('answer');
alert(answer);
if(answer == 'false'){
g_form.setDisplay('u_field',false);
}else{
g_form.setDisplay('u_field',true);
}
}
}
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
Regards,
T Mohan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 03:13 AM
can you explain field is on which table and how this table is linked/related with user table?
please share screenshots.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 03:19 AM
Hi @deepika adimu,
Using Glide Record in Client script is not best practice, Try to use client callable script include to display the field
Script Include :
var TestingScript = Class.create();
TestingScript .prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkFlag: function(){
var sysID = this.getParameter('sysparm_uniqueNum');
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',sysID);
user.query();
if(user.next()){
return user.u_custom_field;
}
},
type: 'TestingScript '
});
and call this script include in On Load Client script to hide the field based on the flag
function onLoad() {
var ga = new GlideAjax('TestingScript ');
ga.addParam('sysparm_name','checkFlag');
ga.addParam('sysparm_uniqueNum',g_user.userID);
ga.getXML(callBack);
function callBack(response){
var answer = response.responseXML.documentElement.getAttribute('answer');
alert(answer);
if(answer == 'false'){
g_form.setDisplay('u_field',false);
}else{
g_form.setDisplay('u_field',true);
}
}
}
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
Regards,
T Mohan.