Sublist.updateTotallingFieldId(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Sets a field as a totalling column, which is used to calculate and display a running total for the sublist.

Returns

serverWidget.Sublist object

Supported Script Types

SuiteScript 2.x Suitelet Script Type and SuiteScript 2.x User Event Script Type (beforeLoad(context))

Governance

None

Module

N/ui/serverWidget Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.id

string

required

The internal ID of the field used to calculate the total field.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/ui/serverWidget Module Script Samples.

Note:

This script sample uses the define function, which is required for an entry point script (a script you attach to a script record and deploy). You must use the require function if you want to copy the script into the SuiteScript Debugger and test it. For more information, see SuiteScript 2.x Global Objects.

          /**
 * @NApiVersion 2.x
 * @NScriptType Suitelet
 */
define(['N/ui/serverWidget', 'N/record'], function(serverWidget, record){
    return {
        onRequest: function(params) {
            var form = serverWidget.createForm({
                title: 'Simple Form'
            });
            var sublistObj2 = form.addSublist({
                id: 'mylist',
                type: serverWidget.SublistType.INLINEEDITOR,
                label: 'List'
            });
            sublistObj2.addField({
                id: 'description',
                type: serverWidget.FieldType.TEXT,
                label: 'Description'
            });
            sublistObj2.addField({
                id: 'amount',
                type: serverWidget.FieldType.CURRENCY,
                label: 'Amount'
            });
            sublistObj2.updateTotallingFieldId({
                id: 'amount'
            });
            sublistObj2.setSublistValue({
                id: 'description',
                line: 0,
                value: 'foo'
            });
            sublistObj2.setSublistValue({
                id: 'amount',
                line: 0,
                value: '10'
            });
            sublistObj2.setSublistValue({
                id: 'description',
                line: 1,
                value: 'bar'
            });
            sublistObj2.setSublistValue({
                id: 'amount',
                line: 1,
                value: '15'
            });
            form.addSublist({
                id: 'dummy',
                type: serverWidget.SublistType.STATICLIST,
                label: 'Dummy'
            });
            params.response.writePage(form);
        }
    };
}); 

        

Related Topics

serverWidget.Sublist
N/ui/serverWidget Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices