Client Script - Auto Populate

rachelconstanti
Mega Sage

Need help with some scripting...

 

This is the scenario -

On the asset table we have a reference field called Project Number (u_project_number) which references cmn_cost_center.

We also have two additional reference fields - Program Manager (u_program_manager) and Program Manager Department (u_program_manager_dept).

Program Manager (u_prog_manager_1) is only a reference field on the cmn_cost_center table.

 

The need:

Auto populate program manager and program manager department based on the project number.

 

Can anyone help?

 

Thank you in advance,

Rachel

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@rachelconstanti You need write two onChange script as follows.

Name: Project Number onChange

Table: alm_asset

UI Type: All

Type: onChange

Field: Project Number

Script:

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

    //Type appropriate comment here, and begin script below
    var getManager = g_form.getReference('u_project_number', referenceCallback);

    function referenceCallback(costCenter) {
		g_form.setValue('u_program_manager',costCenter.u_prog_manager_1);
    }

}

 

Similarly write another script for Program manager field as follows.

 

Name: Program Manager onChange

Table: alm_asset

UI Type: All

Type: onChange

Field: Program Manager

Script:

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

    //Type appropriate comment here, and begin script below
    var getManager = g_form.getReference('u_program_manager', referenceCallback);

    function referenceCallback(manager) {
g_form.setValue('u_program_manager_dept',manager.deparment);
    }

}

 

View solution in original post

2 REPLIES 2

Sandeep Rajput
Tera Patron
Tera Patron

@rachelconstanti You need write two onChange script as follows.

Name: Project Number onChange

Table: alm_asset

UI Type: All

Type: onChange

Field: Project Number

Script:

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

    //Type appropriate comment here, and begin script below
    var getManager = g_form.getReference('u_project_number', referenceCallback);

    function referenceCallback(costCenter) {
		g_form.setValue('u_program_manager',costCenter.u_prog_manager_1);
    }

}

 

Similarly write another script for Program manager field as follows.

 

Name: Program Manager onChange

Table: alm_asset

UI Type: All

Type: onChange

Field: Program Manager

Script:

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

    //Type appropriate comment here, and begin script below
    var getManager = g_form.getReference('u_program_manager', referenceCallback);

    function referenceCallback(manager) {
g_form.setValue('u_program_manager_dept',manager.deparment);
    }

}

 

Thank you!  This works perfectly.
I was missing this piece - costCenter.u_prog_manager_1

I tried just about everything but that