Yes, you should wrap the model. In this case the "preSubmitRecord" function, which is inherited from the Transaction Model, should work fine.
// @method submit Saves the current record
// @return {Transaction.Model.Confirmation}
submit: function() {
if (!this.record) {
throw SC.ERROR_IDENTIFIERS.loadBeforeSubmit;
}
this.preSubmitRecord(); //<-- T
const new_record_id = nlapiSubmitRecord(this.record);
// @class Transaction.Model.Confirmation
const result = {
// @property {String} internalid
internalid: new_record_id
};
return this.postSubmitRecord(result);
// @class Transaction.Model
},
To wrap the function, you can use the "Application.on" listener. You must also require "Application" on the definition of your file.
define('YourFile', [
'Application'
], function(
Application
) {
'use strict';
Application.on('before:Quote.preSubmitRecord', function quoteBeforePreSubmitWrapper(model) {
model.record.setFieldValue(yourCustomField, theValue);
});
});