custom list for contacts related to the entity in address forms

we want a custom list/Record field to select the contact from address form from a sales order. The contacts list should be the related contacts to the customer in the sales order.

go to Customization –> Lists, Records and Fields –> Other record Fields –> new

2 custom List/Record fields:

  • for customer, sourced from entity in address form(hidden)

  • for contact, filtered based on the customer in the customer list.

Compare to field is the custom field created for the address record.

Deploy the Client script in address form:

/**
 * @NApiVersion 2.1
 * @NScriptType ClientScript
 * @NModuleScope SameAccount
 */
/********************************************************************
 * 
 * All Craft Trade Solutions 
 * ACTA-90 : feasibility to Add Contacts in the Shipping Field
 * 
 * ******************************************************************
 * Author: Jobin & Jismi IT Services LLP
 * 
 * Date: 03 October 2024 
 * 
 * Description:  Add contacts in the Shipping Field
 * 
 * Revision History 
 * @version 1.0 initial build :Add contacts list related to the customer in the Address form- JJ0325
 * 
 * 
 ********************************************************************/
define(['N/currentRecord', 'N/search'],
    /**
     * @param{currentRecord} currentRecord
     */
    function (currentRecord, search) {



        /**
         * Function to be executed after page is initialized.
         *
         * @param {Object} scriptContext
         * @param {Record} scriptContext.currentRecord - Current form record
         * @param {string} scriptContext.mode - The mode in which the record is being accessed (create, copy, or edit)
         *
         * @since 2015.2
         */
        function pageInit(scriptContext) {
            try {


                let recordId = scriptContext.currentRecord.id;
                console.log("Record", recordId);


                let entityValue = scriptContext.currentRecord.getValue({ fieldId: 'entity' });
                console.log('entity is', entityValue);
                if(entityValue){
                scriptContext.currentRecord.setValue({fieldId:'custrecord_jj_test_contact_acta_90',value:entityValue});
                }
                


            } catch (e) {
                console.error('Error in pageInit:', e);
               
            }
        }


        function saveRecord(scriptContext) {
            try{
                console.log('inside save record')
            return true;


        }catch(e){
            console.error('error in save record')
            return true
        }
    }
 
         return {
             pageInit: pageInit,
             saveRecord: saveRecord
         };
     });

Deploy the script in address form:

Customization –> Scripting –> Scripts –> New

Create the script record .

Go to Customization –> Forms –> Address Forms

Customize the standard address form.

Select countries to which this address form should be applied.

Upload the client script for address form validation.

Leave a comment

Your email address will not be published. Required fields are marked *