Does anyone know how to create a contact linked to...
# suitescript
c
Does anyone know how to create a contact linked to a customer record with suitescript? I can only seem to do it in the UI… When I add a customer to the contact record, I get the following error on save. I can confirm the customer record is active. Type is ‘individual’. Im able to select the customer using a client script with n/currentRecord. This is my code:
rec = record.create({type: record.Type.CONTACT})
rec.setValue({fieldId: "firstname", value:"Test"})
rec.setValue({fieldId: "lastname", value:"Test"})
rec.setValue({fieldId: "company", value:20042})
rec.save()
n
I don't think you can set contacts for individuals. Since the individual is considered the contact.
Copy code
Yeah no, sorry. Individual = no contacts. One of NS's less inspired design choices...

Either arrange to have the customer be created as a Company (not individual), or you can custom create a custom record to tie contacts to Customers. Keep in mind this will have none of the native functionality, it'll just be a raw association.
s
Did you check record.attach method? This is usually the way to build links between records. 1st you create both contact and customer separately, then link those to each other.