The CreatorCon Call for Content is officially open! Get started here.

Populate child Fields from Parent field record refrence

Michael_Nash
Tera Contributor

I have created a Client script for this but it does not seem to work as expected,

please see below.

 

Please assist with fixing the script 🙂

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    if (newValue) {
        var parent = g_form.getReference('u_parent', popParentInfo);
    }
 
    function popParentInfo(parent) {
        g_form.setValue('u_account_number', parent.account); -displays sys_id
        g_form.setValue('u_dealer_code', parent.account.u_dealer_code); - undefined
        g_form.setValue('u_dealer_name', parent.contact.name); - displays sys_id
        g_form.setValue('u_vin', parent.u_vin); - works fine
    }
}
6 REPLIES 6

Sagar Pagar
Tera Patron

Hi @Michael_Nash,

 

Multiple dot walk will not be supported in getRefernce(). callback functions. You need to convert it to Script Include and GlideAjax.

 


If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar

The world works with ServiceNow

Hi @Sagar Pagar 

 

Would you be able to assist me or guide me in accomplishing this? I'm not familiar with GlideAjax

@Michael_Nash 

 

Refer below link about how to call script include in client script

https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet/ta-p/2312430

 

You need to create client callable script include .

If your code does not work ,just paste it here ,will help you

 

Thanks,

Manjusha Bangale

Hi @Michael_Nash,

 

You can start with referring the documentations. will help you if you stuck.

GlideAjax Example Cheat Sheet (UPDATED) 

GlideAjax Example Cheat Sheet 

 

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar

The world works with ServiceNow