Slig
10/26/2021, 3:01 PMfunction beforeSubmit(context) {
try{
var newRecord = context.currentRecord;
var faturamento = [];
if(newRecord.id){
//carrega um registro do tipo Fatura
var invoiceRecord = record.load({
type: newRecord.type,
id: newRecord.id
});
var termsRecord = record.load({
type: newRecord.type.TERM,
id: 193
});
var terms = termsRecord.getField({
fieldId: "duenextmonthifwithindays"
});
var invoiceLines = invoiceRecord.getLineCount({
sublistId: "installment"
});
for(var i=0; i<invoiceLines ; i++){
//busca o valor de sublista
var duedateLine = invoiceRecord.getSublisValue({
sublistId: "installment",
fieldId: "duedate",
line: i
});
//envia duedateLine para o objeto faturamento
faturamento.push({
duedateLine
});
}
log.debug("invoice", invoice);
if (context.type === context.UserEventType.edit) {
var novaData = new Date(terms);
invoiceRecordRecord.setValue({
fieldId: "duedate",
value: novaData
});
}
invoiceRecord.save();
}
} catch(e){
log.error(e)
}
}
creece
10/26/2021, 3:12 PMfaturamento.push({
duedateLine
});
specify an object property or just push the duedateline with no object.Slig
10/26/2021, 3:15 PMbattk
10/26/2021, 3:17 PMbattk
10/26/2021, 3:18 PMSlig
10/26/2021, 3:21 PM