I'm trying to apply a Journal to a Vendor Bill Pay...
# suitescript
c
I'm trying to apply a Journal to a Vendor Bill Payment and my code is very simple (Map/Reduce). It has worked before but now I get the error "Please enter value(s) for: Account" on the rec.save() line. I've tried both standard and dynamic mode but there's no difference. I suspect this could have something to do with the Apply sublist being very long, there are 3271 lines in it now. When testing earlier it was working fine and the only difference I can think of is that the sublist was much much shorter. It works fine in the UI when I scroll through the pages in the sublist to find the correct journal. Has anyone else had this issue?
Copy code
let rec = record.transform({
    fromType: record.Type.VENDOR_BILL,
    fromId: billId,
    toType: record.Type.VENDOR_PAYMENT
});

let line = rec.findSublistLineWithValue({
    sublistId: 'apply',
    fieldId: 'internalid',
    value: journalId
});

rec.setSublistValue({
    sublistId: 'apply',
    fieldId: 'apply',
    line: line,
    value: true
});

rec.save();
b
usually the limit for lines is higher than 3271 lines
id go with setting the account field, which is usually mandatory
and then seeing if your journal entry was applied
c
Turns out the account field is set when the record is transformed but for some reason checking the apply field on the line unsets it. This is not how it works in the UI which confused me. Setting the account field after applying the journal was, as you suggested, the solution I went with.