I am trying to use the record.copy function but am...
# suitescript
p
I am trying to use the record.copy function but am coming up with a roadblock. When I run the below code as a script snippet in console I get the following error: "You have entered an invalid default value for this record initialize operation." If I remove the defaultValues part of the code I get a different error looking for the name field. What part am I missing in this.
Copy code
require(['N/record'], function(record) {
var recObj = record.copy({
    type: 'customrecord352',
    id: 1407,
    isDynamic: true,
    defaultValues: {
        name: 'test'
    }});
var recordId = recObj.save();
});
Edit: Figured our where I went wrong. Instead of setting the defaultValue I set the field value before the save.
s
Yeah the defaultValues object is for a very small specific set of fields. I don't think you can default anything for custom records.
b
record.name
is what you would use if you wanted to set the default value of a body field