We are trying to create a vendor payment with: ``...
# suitescript
f
We are trying to create a vendor payment with:
Copy code
const vendorPayment = record.create({
    type: record.Type.VENDOR_PAYMENT,
    isDynamic: true,
    defaultValues: {
      entity: vendorId,
    },
  });
and populate the following fields in that order (based on the bill): • subsidiary • currency • apacct • department • location • class • account and then we try to select line items by leveraging:
Copy code
const lineItem = vendorPayment.findSublistLineWithValue({
      sublistId: "apply",
      fieldId: "internalid",
      value: billId,
    });
which works perfectly. However we have one client with thousands of line items and somehow it sometimes does not find the line item (returns
-1
) is there a limit with that method or something else we are missing?
b
its usually favored to use record.transform
f
Ah ok yeah was just looking at that. But transform does not work for
EXPENSE_REPORT
does it?
b
it does, but there is no relation for a vendor payment or bill there
vendor bills are the one with a specific transformation to vendor payment
if you wanted to apply to an expense report, then you would need to use the
bill
or
vendorbills
default value
f
well internally a Expense report is a paid via a vendor payment
/app/accounting/transactions/vendpymt.nl?entity=1032&bill=3751
is the URL in the web interface when hitting make payment on a expense report so I should be able to:
Copy code
const vendorPayment = record.transform({
    fromType: "EXPENSE_REPORT",
    fromId: expenseReportId[0].billId,
    toType: record.Type.VENDOR_PAYMENT,
    isDynamic: true,
  });
?
b
thats actually an example of the usage of a default value, not a record transformation
just like you used the entity default value, use the bill default value
f
sorry I don't fully follow what default value are you talking about?
b
f
ah so I should use
transform
for bill payments but I have to use
create
with ``defaultValues` for EXPENSE REPORTS?
does the order of defaultValues matter? Or is netsuite picking them in the right order?
b
record.transform and the bill default value function similarly
you can just use the bill default value for both
in general code that relies on insertion order of object keys is misguided in javascript
f
Well the issue is that netsuites sublist as well a couple of fields are building ontop of each other don't they?
ok cool thanks for the help. But to your knowledge are there any limitations to number of records the
findSublistLineWithValue
method can work with or is it more likely that some data was not set correctly which made that bill not show up at all on the sublist?
b
suitescript 1.0 and 2.0 are old enough that there is no order
default values are not simply a field that is set a certain value, there is a bunch of logic behind them
other than that,
findSublistLineWithValue
fails at the sublist line limit, or when a sublist filter is used
f
what is the sublist line limit?
f
ah ok so the same limits the UI would have too 🙂 thanks
that was really helpful