Anyone know why I am getting this error trying to ...
# suitescript
m
Anyone know why I am getting this error trying to create a customer payment in a map/reduce script specifically?
Copy code
"name":"INVALID_FLD_VALUE","message":"You have entered an Invalid Field Value 2285 for the following field: customer"
Super basic code is:
Copy code
var paymentRecord = record.create({ type: 'customerpayment', isDynamic: true })
paymentRecord.setValue('customer', customerId)
given the customer seems to be perfectly valid? I can create a payment from that customer in the UI or browser console using transform just fine?
Using record.transform in the map/reduce gave me the dreaded UNEXPECTED_ERROR which is why I switched to create/setValue
And doing create/setValue in console times out (which sucks but suggests the opposite of an invalid customer value)
added a log.audit in the script to confirm the variable value-
Copy code
Audit	customerId - 2285	type - string
(and checked typeof to get string)
r
I don't think what you're doing is possible. A customer payment is a transaction and a customer is an entity. How the one would become the other doesn't seem possible to me.
m
? It's one of the standard transform actions. But even if not what I'm doing in the script is creating a customer payment record and adding the customer (field is
customer
not
entity
in this case I think?)
r
weird what you're doing is almost exactly what they have in the docs
m
Yeah this should be super standard/basic from my understanding/past experience
r
ah
Note: When you use this transformation, do not use Record.setValue(options) to set the value of the
customer
field on the resulting Customer Payment record. This field is populated automatically during transformation, and you cannot specify a value for this field after the transformation is complete.
m
Yep, but I'm not doing that
r
your first reply appears to be doing that
m
Copy code
var paymentRecord = record.create({ type: 'customerpayment', isDynamic: true })
paymentRecord.setValue('customer', customerId)
is not using transform
That's a basic create record and set value. When I try using
transform
I do not set the customer record via setValue. Both should yield me the same result
r
sorry, i shouldn't have chimed in. never used the transform API
m
No worries, I appreciate your time and help reptar!
👍 1
I ran the code in the script debugger and it worked fine too??
I figured it out, there was something wrong with the value being passed. I think some sort of extraneous spacing somewhere
👍 1
👍🏻 1