Disable the amount field for EUR and USD sublist in Item record

We can implement the customisation using User event script. In the item record , amount field for USD and EUR set to disable by default when the item page loaded forĀ individual items and assemblies.

User Event Script

/**
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 */
define(['N/record','N/ui/serverWidget','N/error'],
    
    (record,serverWidget,error) => {
        /**
         * Defines the function definition that is executed before record is loaded.
         * @param {Object} scriptContext
         * @param {Record} scriptContext.newRecord - New record
         * @param {string} scriptContext.type - Trigger type; use values from the context.UserEventType enum
         * @param {Form} scriptContext.form - Current form
         * @param {ServletRequest} scriptContext.request - HTTP request information sent from the browser for a client action only.
         * @since 2015.2
         */
        const beforeLoad = (scriptContext) => {
                try{
                        log.debug("inside beforeload");
                        if(scriptContext.type == 'view' || scriptContext.type == 'edit'){
                                var form = scriptContext.form;
                                var newFieldview = form.addField({
                                        id: 'custpage_resource_tab',
                                        type: 'INLINEHTML',
                                        label: 'Resource Tab'
                                });
                                var html = `<script>jQuery( document ).ready(function() {document.querySelectorAll('table#price4_splits tbody tr>td:nth-child(6)').forEach(function (el) { el.innerText = " " }); document.querySelectorAll('table#price2_splits tbody tr>td:nth-child(6)').forEach(function (el) { el.innerText = " " });});</script>`;
                                log.debug("html",html);
                                newFieldview.defaultValue = html;
                        }
                        
                }
                catch (e) {
                        log.debug("error@beforeload",e);
                        log.error("error@beforeload",e);
                }

        }

        return {beforeLoad}

    });

Leave a comment

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