Reputation: 195
How to set sublist value when using in client script. I tried all the method but it's not working and returning the same error.
fieldChanged: function(context){
var record = currentRecord.get();
//var record = context.currentRecord; // not working
if(context.fieldId =='custpage_cancel'){
var objSublist = record.getSublist({ //returns sublist obj but can not set
sublistId: 'custpage_sublist'
});
objSublist.setSublistValue({ // Not working ERROR: objSublist.setSublistValue is not a function
fieldId : 'custpage_id',
line : 0,
value : true
});
// record.setSublistValue({ // Not working ERROR: objSublist.setSublistValue is not a function
// sublistId: 'custpage_sublist',
// fieldId: 'custpage_id',
// line: 0,
// value: true
// });
}
}
ERROR: Screenshot
Upvotes: 4
Views: 20909
Reputation: 1
try to do the same with a custom list sublist "list" and throw me error
User event Script
function beforeLoad(){
var form = scriptContext.form;
var sublistaAplicar=form.addSublist({
id: 'custpage_invoice',
type: 'list',
label: 'Facturas',
tab: 'custpage_aplicar'
});
sublistaAplicar.addField({
id : 'custpage_type',
type : serverWidget.FieldType.TEXT,
label : 'Type'
});
}
client script.js
function validateField(scriptContext) {
var currentRecord = scriptContext.currentRecord;
var lineNum = currentRecord.selectLine({
sublistId: 'custpage_invoice',
line: 0
});
currentRecord.setCurrentSublistValue({
sublistId: 'custpage_invoice',
fieldId: 'custpage_type',
value: 'test',
ignoreFieldChange: true
});
currentRecord.commitLine({
sublistId: 'custpage_invoice'
});
}
Upvotes: 0
Reputation: 7
You may need to use the command of inserting new line first before you select the line when you are on the client script.
Upvotes: -4
Reputation: 486
Try selecting the line and set the value , In netsuite for current record they prefer to use select line and set values
var records = context.currentRecord
var lineNum = records .selectLine({
sublistId: 'custpage_sublist',
line: 0
});
records.setCurrentSublistValue({
sublistId: 'custpage_sublist',
fieldId: 'custpage_id',
value: true,
ignoreFieldChange: true
});
records.commitLine({
sublistId: 'sublistidentire'
});
Upvotes: 7