Visible the variable based on requested for
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 08:01 PM
Hello team,
We have a requirement for to create a catalog onchange client script if the requested for is a VP or director or CEO then the variable won't be visible to select and otherwise it will be visible to select for remaining people. Please provide a script to achieve this requirement.
Thanks!!
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 08:31 PM - edited 05-28-2024 08:32 PM
Hi @Surendra6
You can try the below script
On change client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var requestedFor1 = g_form.getValue('opened_by');
//alert(requestedFor1);
var ga = new GlideAjax('GetManagerDetailsScript');
ga.addParam('sysparm_name', 'getVipvalue');
ga.addParam('sysparm_requested_for1', requestedFor1);
ga.getXMLAnswer(callback);
function callback(response) {
var answer = response;
alert(answer);
if (answer == 'true') {
alert("tetsing"); // change the line based upon your need
} else {
alert('testing failed'); // change the line based upon your need
}
}
//Type appropriate comment here, and begin script below
}
Script include :
var GetManagerDetailsScript = Class.create();
GetManagerDetailsScript.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getVipvalue: function() {
var requestedFor = this.getParameter('sysparm_requested_for1');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', requestedFor);
gr.query();
if (gr.next()) {
return gr.vip;
}
}
});
Thanks and Regards
Sai Venkatesh