0

I'm currently building an integration with Netsuite using the Suitetalk REST API. I would like to retrieve the role of each contact associated with a customer to find the Primary and Operational contacts of the customer.

I have tried querying the customer endpoint:

record/v1/customer/ {customerId} /contact/ {contactId} /contactrole

This query returns Role id 14 which is 'Customer Center' for all customer contact records. This is obviously incorrect as this information is returned for contacts tagged with different roles when I check them via the UI.

I have also tried using Suiteql using the query endpoint with the similar results.

Is the query incorrect or should I be using a different endpoint? I have been stuck for days, so I would appreciate any suggestion.

UPDATE

I managed to get the customer contact roles via the following SuiteQL query:

{
  "q" : "SELECT Contact.email, Contact.entityid, ContactRole.name as role FROM Customer LEFT JOIN CustomerCompanyContact ON ( CustomerCompanyContact.ContactsCompany = Customer.ID ) LEFT JOIN Contact ON ( CustomerCompanyContact.contact = Contact.ID ) LEFT JOIN ContactRole ON ( Contact.ContactRole = ContactRole.id ) WHERE ContactRole.name IN ('Primary Contact','Operational contact') AND Customer.entityid IN ('exampleCompanyId') ORDER BY Contact.datecreated DESC"
}
Mintelek
  • 1
  • 1

2 Answers2

0

A long comment. Hopefully it helps focus your search for a solution.

Contact Roles is the subrecord for contacts who have login access to a customer's account. The role listed there is the access role. Customer Center is the default access role in a vanilla Netsuite account.

The Records Catalog has contactList as the joining table for contact to company. I don't see any mention of role there that would correspond to contactrole in the records browser so it appears some documenation is missing.

You'll likely have to play with the SuiteQL queries feature to get this. See Executing SuiteQL Queries Through REST Web Services in the NS help.

bknights
  • 14,408
  • 2
  • 18
  • 31
  • Thanks for the tip. I have also tried Suiteql with no luck so far. I tried to query a table called Contact role map to see if that's how contacts arrinked to customers but the query returned a table not found error. I will try looking into the contactList table to see if that gets me somewhere. – Mintelek Jul 12 '22 at 18:55
0

with suiteql you can get primary contact with this

{ "q": "select cus.companyname,cus.contact,cont.entityid from customer cus left outer join contact cont on cus.contact=cont.id where cus.id=<<id of ur customer>>"}