Afternoon, I’m trying to create a `creditcardcharg...
# suitescript
c
Afternoon, I’m trying to create a
creditcardcharge
record, I get as far as the
account
field and get this error back:
Copy code
You have entered an Invalid Field Value 129 for the following field: account
I can create an identical record in the UI with this same value and it works. Any ideas?
p
Share your code, or @battk will ask you to :)
😂 1
c
lol
Copy code
let r = record.create({
			type: 'creditcardcharge',
			isDynamic: true
		});	
		r.setValue({ fieldId: 'entity', value: trans.ns_vendor_id });
		r.setValue({ fieldId: 'currency', value: vendorAttribs.currency.value });
		r.setValue({ fieldId: 'postingperiod', value: trans.ns_accounting_period });
		r.setValue({ fieldId: 'subsidiary', value: vendorAttribs.subsidiary.value });
		r.setValue({ fieldId: 'account', value: credit.toString() });
		r.save();
b
ive only got general dynamic mode rules
set the same fields in the same order you would in the ui
in this case, i suspect either the entity or subsidiary arent being set correctly, so you should probably hardcode those
otherwise use Field.getSelectOptions to see your select options
c
Thank you, I’m working through your suggestions now.
Turns out that I can’t read. Just needed to rubber duck this one I guess.
Everything working fine now… lol.
z
@battk mentioned one extremely important thing : order of setting values for fields! Setting value in SuiteScript is almost equal to setting in UI... it triggers events, sourcing etc.. That's why you should at least follow sequence from UI form. For example, setting account before subsidiary will produce error..