How to Auto Populate Manager in catalog item request

krishna115
Tera Contributor

I crated "Demo Catalog Project" Catalog Item and Some Variables in that item. If user selects any Requester(sys_user). Then Manager field (single line text) should be auto populated with requester Manager. 

I created below catalog OnChange client script but auto populating only sys_id of Manager.

Please correct my script.

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

 var user = g_form.getValue('requester');
 var mgr = new GlideRecord("sys_user");
 mgr.addQuery("sys_id", user);
 mgr.addQuery();
 while(mgr.next())
 {
 g_form.setValue("manager", mgr.manager);


   }

}

10 REPLIES 10

Snow_123
Tera Contributor

if am not wrong., it is client script we cannot write server script like glide record.