On change client script issue for reference variable

RudhraKAM
Tera Guru

We have a table (cmdb_ci_appl)  where there is no Display value. 

we have a catalog item in which we have a reference field, on selecting the 1st field we need to populate the 3 other fields.

How to set the app ID ( which is highlighted) upon selecting? ( as of now it is defaulting to name , which is on the left side)

 

Below is the Onchange CS script ( for some reason when the ID is selected it is not setting the name in the name field (name is of string type on the table ) 

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

    var AppID = g_form.getReference('citrix_application_id', SetApplicationvariables);

    function SetApplicationvariables(AppID) {

        g_form.setValue('citrix_application_name', AppID.name);
        g_form.setValue('citrix_application_version', AppID.version);
        g_form.setValue('citrix_application_vendor_name', AppID.u_common_name);

    }

}

 

 

12 REPLIES 12

Hi,

this should be fine but remember along with the field which is Display=true user will see data from u_number when they try to type in the reference variable

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@RudhraKAM 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

suvro
Mega Sage
Mega Sage

Try this Zero Code approach

https://community.servicenow.com/community?id=community_article&sys_id=3f0cf115db7fc190847d5ac2ca961931

Hi @RudhraKAM ,

Did you try this zero code method. It is very simple to use.

Tried this too but seems the application name is not populating, rest of the fields are populating in native view but not in portal view