- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2023 10:59 AM
In client script (on change, variable : Application) if senmanager value is blank it should return 'Requested For' Manager name.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('applicationIDPopulation');
ga.addParam("sysparm_name", "getApplicationDetails");
ga.addParam("sysparm_id", g_form.getValue('application_id'));
ga.getXML(getResponse);
function getResponse(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
var result = JSON.parse(answer);
g_form.addInfoMessage(g_form.getValue('application_id'));
g_form.setValue('populate_application_id', result.num);
g_form.addInfoMessage(result.senmanger);
if (result.senmanger != '') {
g_form.setValue('u_level_approval', result.senmanger);
} else if (result.senmanger == '') {
var id = g_form.getValue('request_for');
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',id);
user.query();
if (user.next()) {
g_form.setValue('u_level_approval', user.manager);
}
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2023 12:30 AM
Hello @nkumari,
Please update your client script with below and test your functionality :
Onchange field : Application Supervisor
Note : The default script contains a line that checks for newValue == ''" . You can remove that from if statement in the script and it will run below code.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading ) {
return;
}
var appSupervisor = g_form.getValue('application_supervisor');
alert(appSupervisor);
var reqName = g_form.getValue('requested_for');
var user = g_form.getReference('requested_for', doAlert);
function doAlert(user) {
alert('inside alert');
if (appSupervisor == '') {
alert("inside if");
g_form.setValue('requested_for_manager', user.manager);
}
}
}
Please mark Correct and click the Thumb up if my answer helps you solved your issue. Thanks!
Appreciate your help !
Thank you.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2023 06:31 AM
Correct it helped me