- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2025 02:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2025 02:43 AM
Do this
1) onLoad catalog client script and GlideAjax with UI Type-Portal
var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkRecordPresent: function(){
// check if logged in user is manager of someone or not
var gr = new GlideRecord('sys_user');
gr.addQuery('manager', gs.getUserID());
gr.setLimit(1);
gr.query();
return gr.hasNext().toString();
},
type: 'checkRecords'
});
Client Script:
function onLoad() {
var ga = new GlideAjax('checkRecords');
ga.addParam('sysparm_name', "checkRecordPresent");
ga.getXMLAnswer(function(answer) {
if (answer == 'false') { // means logged in user is non manager
g_form.setDisplay('variable1', false);
g_form.setDisplay('variable2', false);
} else {
g_form.setDisplay('variable1', true);
g_form.setDisplay('variable2', true);
}
});
//Type appropriate comment here, and begin script below
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2025 02:43 AM
Do this
1) onLoad catalog client script and GlideAjax with UI Type-Portal
var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkRecordPresent: function(){
// check if logged in user is manager of someone or not
var gr = new GlideRecord('sys_user');
gr.addQuery('manager', gs.getUserID());
gr.setLimit(1);
gr.query();
return gr.hasNext().toString();
},
type: 'checkRecords'
});
Client Script:
function onLoad() {
var ga = new GlideAjax('checkRecords');
ga.addParam('sysparm_name', "checkRecordPresent");
ga.getXMLAnswer(function(answer) {
if (answer == 'false') { // means logged in user is non manager
g_form.setDisplay('variable1', false);
g_form.setDisplay('variable2', false);
} else {
g_form.setDisplay('variable1', true);
g_form.setDisplay('variable2', true);
}
});
//Type appropriate comment here, and begin script below
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2025 09:04 AM
@Ankur Bawiskar Thank you so much, It worked for me!!