Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

fields are not mapped on backend table when request is submitted using record producer

SakshiBagal
Tera Contributor

I have created record producers , I am having supplier name reference fields and on selection of supplier name field 4 fields gets autopopulated on the form but it is not getting saved to backend table.

2 REPLIES 2

JenniferRah
Mega Sage
Mega Sage

Where are you setting those four fields? Are you setting them in your script of the record producer? If so, we may need to see that code to see if there might be an issue.

MaxMixali
Kilo Sage

in Client Script

Make sure you're using g_form.setValue() (not just setting display values) in your onChange client script:

Record Producer Client Script (onChange):

 
 
javascript
function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    
    // Get supplier details
    var supplierID = newValue;
    
    var ga = new GlideAjax('SupplierUtils');
    ga.addParam('sysparm_name', 'getSupplierDetails');
    ga.addParam('sysparm_supplier_id', supplierID);
    ga.getXMLAnswer(function(response) {
        var details = JSON.parse(response);
        
        // Use setValue to populate AND save the fields
        g_form.setValue('supplier_address', details.address);
        g_form.setValue('supplier_phone', details.phone);
        g_form.setValue('supplier_email', details.email);
        g_form.setValue('supplier_contact', details.contact);
    });
}




Hello i hope that can help

If you find this answer useful, please mark it as solution accepted/helpful

Massimiliano Micali