- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 01:24 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 01:45 AM
Hi @praveen1231 ,
Try the following onLoad Catalog client script and a Client Callable Script Include.
Catalog Client Script:
function onLoad() {
var ga = new GlideAjax('UserDataUtils');
ga.addParam("sysparm_name", "getTitle");
ga.addParam("sysparm_user_id", g_user.userID);
ga.getXMLAnswer(validateUser);
function validateUser(answer) {
if (answer.indexOf('CIO') != -1 || answer.indexOf('CEO') != -1) {
g_form.setReadOnly('your_field_name', true);// Change field name as per your requirement
}
}
}
Client Callable Script Include:
var UserDataUtils = Class.create();
UserDataUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getTitle: function(){
var user_id = this.getParameter('sysparm_user_id');
var usrGr = new GlideRecord('sys_user');
if(usrGr.get(user_id)){
return usrGr.getValue('title') + '';
}
},
type: 'UserDataUtils'
});
Please mark my answer helpful and accept as solution if it helped you 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 01:32 AM
Hello @praveen1231 ,
you can create an onload catalog client script. use the g_form.getUserID() which you give you the current logged in user and dot walk check the title in if loop.
later user g_form.setReadOnly('varaible_name',true);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 01:41 AM
use g_user.getUserID() there is also another way calling the script inlcude in client script using glideajax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 01:45 AM
Can you please share me the entire code of client script. And need to check the user with title.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 01:45 AM
Hi @praveen1231 ,
Try the following onLoad Catalog client script and a Client Callable Script Include.
Catalog Client Script:
function onLoad() {
var ga = new GlideAjax('UserDataUtils');
ga.addParam("sysparm_name", "getTitle");
ga.addParam("sysparm_user_id", g_user.userID);
ga.getXMLAnswer(validateUser);
function validateUser(answer) {
if (answer.indexOf('CIO') != -1 || answer.indexOf('CEO') != -1) {
g_form.setReadOnly('your_field_name', true);// Change field name as per your requirement
}
}
}
Client Callable Script Include:
var UserDataUtils = Class.create();
UserDataUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getTitle: function(){
var user_id = this.getParameter('sysparm_user_id');
var usrGr = new GlideRecord('sys_user');
if(usrGr.get(user_id)){
return usrGr.getValue('title') + '';
}
},
type: 'UserDataUtils'
});
Please mark my answer helpful and accept as solution if it helped you 👍✔️
Anvesh