Good afternoon, When trying to create a contact, I...
# suitescript
s
Good afternoon, When trying to create a contact, I'm getting ReferenceError: "Contact" is not defined This is the syntax I'm using record.create({ type: contact, isDynamic: true, defaultValues: { entity: contactid } }); What am I doing wrong ? Thanks
s
Contact
is likely a variable elsewhere in your program - and it's undefined 🙂
actually, if you mean lower case
contact
then it could be your
contact
type: parameter
you should use record.Type.CONTACT
e.g.
record.create({ type: record.Type.CONTACT, ...)
(going from memory here)
s
Getting closer 🙂 I have another message message":"You have entered an invalid default value for this record initialize operation.","stack": I guess something is wrong here record.create({ type: record.Type.CONTACT, defaultValues: { entity: 1406 } Having said that, when I used SuiteQL, I do SELECT id, firstname, lastname,email, phone, title FROM contact WHERE company = and it's working, hence I tried record.create({ type: record.Type.CONTACT, defaultValues: { company: 1406 } but same problem any idea
d
I don't think that creating a contact record supports any default values: N/record Default Values
s
that official list of default values is the gold standard, but it's only a subset of what is possible
🤔 1
@Simon when you create the record, why not just set
entity
directly after, why 'default values' at record creation?
e.g.
const c = new Contact();  c.entity = 1406
@David B I'm just saying, undocumented and hence probably unsupported, there are initialize values you can send for some records that are not in the list
d
yeah, pretty much any parameter in the URL when you're using the UI? I've seen that with transformations. Doing it in the UI first seems to always be the answer. Also, it seems like the default value is `parent`: system.netsuite.com/app/common/entity/contact.nl?parent=1
s
Aye, though for @Simon case, unless he must initialize it, I'd recommend avoiding that and just setting the entity property later. Avoid undocumented behavior.
actually, maybe it's
parent
he needs to set, based on your url finding, but still doing so after record creation but before save is advisable over undocumented
defaultValues
☝️ 1
b
NetSuite makes the list of available default values (initialized defaults) gettable in client side script contacts have a pretty standard list of default values, none of which are entity or parent
Copy code
{
  "initializedefaults": [
    "customform",
    "enablefieldtriggers",
    "enablefieldpermissions",
    "disabletriggers",
    "recordmode",
    "cf",
    "sobcmode",
    "shoppernexus",
    "print",
    "advancedprint",
    "is",
    "ps",
    "pt",
    "bom",
    "hasrm",
    "popup",
    "rmloaddata",
    "userm",
    "nameprefix",
    "deletionreason",
    "deletionreasonmemo",
    "platformtype",
    "ignorecache"
  ],
  "transformdefaults": [
    "customform",
    "enablefieldtriggers",
    "enablefieldpermissions",
    "disabletriggers",
    "recordmode",
    "cf",
    "sobcmode",
    "shoppernexus",
    "print",
    "advancedprint",
    "is",
    "ps",
    "pt",
    "bom",
    "hasrm",
    "popup",
    "rmloaddata",
    "userm",
    "nameprefix",
    "deletionreason",
    "deletionreasonmemo",
    "platformtype",
    "ignorecache"
  ],
  "id": "contact",
  "type": "ENTITY",
  "scriptable": true,
  "url": "/app/common/entity/contact.nl"
}
👌 1