Reputation: 11
I'm writing a user event script beforeSubmit on the payment screen. How do reference the transaction ID of the bill that is being paid before the payment record is created? I need to know if I am paying an expense report or a normal vendor bill so I can prefix the check # field. This is what I have so far.
define(['N/record'],
function(record) {
function beforeSubmit(context) {
if (context.type !== context.UserEventType.CREATE)
return;
var customerRecord = context.newRecord;
>>>>>> Not sure how to reference the Vendor Bill <<<<<
var newprefix = 'EXP';
newprefix += customerRecord.getValue('tranid');
customerRecord.setValue('tranid', newprefix);
}
return {
beforeSubmit: beforeSubmit
};
});
thanks
*** The code I added to work out if the Vendor Bill is an Expense Report:
var index = paymentRecord.findSublistLineWithValue({"sublistId": "apply", "fieldId": "apply", "value": "T"});
var sublistFieldTranstype = paymentRecord.getSublistValue({
sublistId: 'apply',
fieldId: 'trantype',
line: index
});
if (sublistFieldTranstype !== 'ExpRept')
return;
Upvotes: 1
Views: 1390
Reputation: 8847
You'll need to inspect the apply
sublist to see which transaction(s) your Payment record is being applied to.
See the Vendor Payments Record Browser for all of the fields available in the apply
sublist.
Upvotes: 2