hey all, trying to create a customer payment via S...
# suitescript
a
hey all, trying to create a customer payment via SS through a restlet, but am not able to get it to work- various errors depending on which fields i comment out in the process…
Copy code
var outstandingAmount = Number(payments[i].outstanding_amount); 
     // outstandingAmout is 800
     var customerpayment = record.create({ type: 'customerpayment', isDynamic: true });
     customerpayment.setValue({ fieldId: 'customer', value: customer });
     customerpayment.setValue({ fieldId: 'undepfunds', value: false });
     customerpayment.setValue({ fieldId: 'account', value: 419 });
     customerpayment.setValue({ fieldId: 'payment', value: outstandingAmount });
     customerpayment.setValue({ fieldId: 'autoapply', value: true });
     customerpayment.setValue({ fieldId: 'memo', value: 'created from the restlet' });
     var outstandingPmt = customerpayment.save();
b
radio boxes act funny
try using 'F' instead of false
otherwise the rest looks okay
you may want to make sure that you can create the record in the ui
you've chose to auto apply, which is honestly unreliable and only works if there are transactions to apply against
a
ok, so your feedback on the radio buttons was spot on
that fixed that issue
the restlet will only be creating customer payments if the customer has outstanding invoices..otherwise we are just creating deposits
and i know that this customer has invoices to auto apply to .. def tested in the UI first, and it all works
but still getting the error when entering an amount into the
payment
field
Copy code
"Value 0.0 outside of valid min/max range for field payment"
even if i hard-code 1000 into my script..
b
you may want to use the invoices entity default value to choose your customer
and maybe the invoices default paarameter to choose which invoices you are paying
checking all the apply checkboxes may be the last resort
a
right but i still am unable to populate the payment amount field
so even if i wanted to apply to every invoice, i would still need to enter an amount
or checking apply will autopopulate the
payment
amount for all of them
b
my guess is that netsuite thinks there are no outstanding invoices
so its not letting you change the payment amount
a
message has been deleted
same customer in the ui
and i can enter it manually without an issue 😞
b
what does the scripted record say
you can count the number of invoices via script
e
could `isDynamic:true`be messing with it?
b
could be, i personally expect it to be the filters like
select item
or
date
a
count the invoices how?
via the sublist? or just searching for open invoices?
sublistId should be apply
a
yeah, i checked, linecount = 0
wtf NS
b
as i said no invoices
a
so weird
b
my guess would be the user filters
you can try ignoring the user filters by following the instructions for Deposits
i usually recommend just using choosing which invoices you wish to pay using default values
a
payment is coming from an external system, which doesn’t know the individual invoices/amounts, just the outstanding balance from the customer record
b
choose for them
oldest first is probably reasonable
a
well, user filters doesn’t work, gives me an invalid initalize value when i try to set it to false, and if i can’t read the sublist lines how can i select the invoices
b
my suggestion about default values 24 minutes ago
a
i will have to look into it