Understanding Sublist.updateTotallingFieldId(options) in NetSuite SuiteScript

The Sublist.updateTotallingFieldId(options) method is used in NetSuite’s SuiteScript 2.x to update the field ID responsible for calculating the total value of a sublist. This is particularly useful when dealing with custom transaction sublists where a total field needs to be dynamically reassigned based on business logic.

SYNTAX:

sublist.updateTotallingFieldId({
    id: 'total_field_id'
});

Key Use Cases

1. Updating the Totaling Field Dynamically

In transactions where the total amount is derived from different fields based on conditions, updateTotallingFieldId can be used to switch the totalling field dynamically.

2. Customizing Summary Calculations in Sublists

If a custom sublist contains multiple amount fields, you can designate which field should contribute to the total dynamically without modifying the default NetSuite behavior.

Sample Script:

// Add a sublist to display custom record entries
          let updateSublist = form.addSublist({
            id: 'custpage_gold_records',
            type: serverWidget.SublistType.INLINEEDITOR,
            label: 'Update Expiry Tracker',
          });

          // Add columns to the sublist
          updateSublist.addField({
            id: 'custpage_col_expiry_tracker_id',
            type: serverWidget.FieldType.SELECT,
            label: 'Expiry Tracker ID',
            source: 'customrecord_jj_export_gold_expiry_track'
          }).updateDisplayType({
            displayType: serverWidget.FieldDisplayType.DISABLED,
          });
          updateSublist.addField({
            id: 'custpage_col_serial_lot_no',
            type: serverWidget.FieldType.SELECT,
            label: 'Serial/Lot Number',
            source: 'inventorynumber'
          }).updateDisplayType({
            displayType: serverWidget.FieldDisplayType.DISABLED,
          });
          updateSublist.addField({
            id: 'custpage_col_bill_date',
            type: serverWidget.FieldType.DATE,
            label: 'Bill Date',
          }).updateDisplayType({
            displayType: serverWidget.FieldDisplayType.DISABLED,
          });
          updateSublist.addField({
            id: 'custpage_col_ir_date',
            type: serverWidget.FieldType.DATE,
            label: 'IR Date',
          }).updateDisplayType({
            displayType: serverWidget.FieldDisplayType.DISABLED,
          });
          updateSublist.addField({
            id: 'custpage_col_expiry_date',
            type: serverWidget.FieldType.DATE,
            label: 'Expiry Date',
          }).updateDisplayType({
            displayType: serverWidget.FieldDisplayType.DISABLED,
          });
          updateSublist.addField({
            id: 'custpage_col_remaining_qty',
            type: serverWidget.FieldType.FLOAT,
            label: 'Quantity',
          }).updateDisplayType({
            displayType: serverWidget.FieldDisplayType.DISABLED,
          });
          updateSublist.addField({
            id: 'custpage_col_used_qty',
            type: serverWidget.FieldType.FLOAT,
            label: 'Quantity Used',
          });
          updateSublist.addField({
            id: 'custpage_col_loss_percentage',
            type: serverWidget.FieldType.PERCENT,
            label: 'Loss Percentage',
          });
          updateSublist.addField({
            id: 'custpage_col_loss_qty',
            type: serverWidget.FieldType.FLOAT,
            label: 'Loss Quantity',
          }).updateDisplayType({
            displayType: serverWidget.FieldDisplayType.DISABLED,
          });
          updateSublist.addField({
            id: 'custpage_col_total_qty_used',
            type: serverWidget.FieldType.FLOAT,
            label: 'Total Quantity Used',
          }).updateDisplayType({
            displayType: serverWidget.FieldDisplayType.DISABLED,
          });
          updateSublist.addField({
            id: 'custpage_col_balance_qty',
            type: serverWidget.FieldType.FLOAT,
            label: 'Balance Quantity',
          }).updateDisplayType({
            displayType: serverWidget.FieldDisplayType.DISABLED,
          });
          updateSublist.updateTotallingFieldId({
            id: 'custpage_col_total_qty_used'
          });

Leave a comment

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