- 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
03-31-2023 01:03 PM
GlideRecord should not be used client side, instead use g_form.getReference for the 'request_for' user reference with a callback function to set the 'u_level_approval' variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2023 09:36 AM
Hi @nkumari you can use GlideRecord in client side scripting if you can give field names i can write the script for you. You can also connect with me in LinkedIn Uday Kumar Valapudasu and connect in zoom.
If my solution helps you please mark my Solution Accepted and Helpful.
Thanks and regards
Uday Kumar Valapudasu
- 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-02-2023 11:30 AM
Hello @nkumari ,
Please accept the solution and mark my answer helpful!
Appreciate your help!
Thank you.
Thank you.