Sublist.updateTotallingFieldId(options)
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 |
Suitelets User event scripts -beforeLoad entry point For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2015.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
string |
required |
The internal ID of the field used to calculate the total field. |
Syntax
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.
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);
}
};
});