Setting Default Values on Record Creation

For some reason, whenever I try to use record.create() and set default values in SuiteScript, I get this error message: “You have entered an invalid default value for this record initialize operation.”

I can’t figure out why the error. The only field I’m setting is the name field and the value is a string, which I’m able to set successfully in the UI. The field ID seems to be correct (altname). It’s a UE script. The only thing I can think of is maybe custom records aren’t supported.

Anyone else run into this?

Beginner Asked on April 18, 2020 in SuiteCloud.
Add Comment
1 Answer(s)

I’ve run into issues trying to load fields using the defaultValues parameter for some fields.  Instead, try loading values with the setValue statement.  Sample below:

var newcustrec = record.create({
type: ‘customrecord_my_customrec’,
isDynamic: true});

newcustrec.setValue({
fieldId: ‘custrecord_sample_qty’,
value: 100});

newcustrec.save();

Rookie Answered on December 3, 2024.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   SuiteMigration   Become a Sponsor