The client Script to set addressee field on the address form as empty

/**

 * @NApiVersion 2.1

 * @NScriptType ClientScript

 * @NModuleScope SameAccount

 */

define([],

    /**

     * @param{currentRecord} currentRecord

     * @param{record} record

     */

    function() {

        /**

         * 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{

                console.log("In pageInit",scriptContext.currentRecord);

                if(scriptContext.mode == 'create'){

                    if(scriptContext.currentRecord.getValue({fieldId:'country'}) == 'AU'){

                        scriptContext.currentRecord.setValue({

                            fieldId: 'addressee', 

                            value: ' '

                        });

                    }

                }

            }

            

            catch (e) {

                log.error({title: "error@pageInit", details: e});

            }

    

        }

        return {

            pageInit:pageInit

                      

        };

    });

Leave a comment

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