RE: Transform a salesrecord to invoice through clientscript
Im trying to transform salesorder record to invoice,but Im getting Invalid Initilize error and invalid refernce.but I have given form Id as internalId y Im getting this error can Any one help me
function saveRecord(context) {
var objRecord = record.transform({
fromType: record.Type.SALES_ORDER,
fromId:22367,
toType: record.Type.INVOICE,
isDynamic: true,
});
}
In the above code I had done mistake,that is I did’nt save the record that is the reason the salesorder is not transform to Invoice now its working fine.
/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define([“N/log”, “N/email”, “N/record”], function(log, email, record) {
function afterSubmit(scriptContext) {
var newOrderId = scriptContext.newRecord.id;
var objRecord = record.transform({
fromType: record.Type.SALES_ORDER,
fromId: newOrderId,
toType: record.Type.INVOICE,
isDynamic: true
});
// Add additional code.
var recordId = objRecord.save({
enableSourcing: true,
ignoreMandatoryFields: true
});
// Add additional code.
}
return {
afterSubmit: afterSubmit
}
});
we can see changes in releated recods subtab,the inovice is created.