Bibek Shrestha
08/20/2020, 4:46 PMBibek Shrestha
08/20/2020, 4:46 PM/**
*@NApiVersion 2.x
*@NScriptType Restlet
*/
define(['N/record', 'N/error'],
function (record, error) {
function post(context) {
// Initialize a new vendor bill record
var vendorBillRec = record.create({
type: record.Type.VENDOR_BILL,
isDynamic: false
});
vendorBillRec.setValue({
fieldId: 'account',
value: context.account
})
vendorBillRec.setValue({
fieldId: 'entity',
value: context.entity
})
vendorBillRec.setValue({
fieldId: 'exchangerate',
value: context.exchangerate
})
vendorBillRec.setValue({
fieldId: 'terms',
value: context.terms
})
vendorBillRec.setValue({
fieldId: 'usertotal',
value: context.usertotal
})
vendorBillRec.setValue({
fieldId: 'approvalstatus',
value: context.approvalstatus
})
var expense = context.expense;
vendorBillRec.setSublistValue({
sublistId: 'expense',
fieldId: 'account',
line: 1,
value: expense.account
})
log.debug('amount', expense.amount);
vendorBillRec.setSublistValue({
sublistId: 'expense',
fieldId: 'amount',
line: 1,
value: parseFloat(expense.amount)
})
vendorBillRec.setSublistValue({
sublistId: 'expense',
fieldId: 'memo',
line: 1,
value: expense.memo
})
vendorBillRec.setSublistValue({
sublistId: 'expense',
fieldId: 'custcol_scm_lc_autocalc',
line: 1,
value: expense.custcol_scm_lc_autocalc
})
var recId = vendorBillRec.save({
enableSourcing: true,
ignoreMandatoryFields: false
});
return JSON.stringify(recId);
}
return {
post: post
};
}
);
Bibek Shrestha
08/20/2020, 4:47 PMerror.SuiteScriptError
with message Please enter value(s) for: Amount
stalbert
08/20/2020, 7:02 PMrecId
before returning itBibek Shrestha
08/20/2020, 7:07 PM