2

I am creating a script that needs to get the contacts associated to a company. The script needs to work for both Customers and Vendors.

You can attach a Contact to a Customer or Vendor from the record screen and by doing this you can attach a Contact with an empty Company field.

enter image description here

I can use the sublist contactroles if it is a Customer record but that sublist is not available for the Vendor record.

Is there a way to get the contact records via search? So using the screenshot above can a search get the following contacts: Aiden Somerhalder, Alex Wolfe and Gerrom Test Contact.

Rusty Shackles
  • 2,802
  • 10
  • 11

2 Answers2

2

I'd create a saved search of Vendors/Suppliers.

Add a filter to your result: contact : name is not empty

Add a column to your result: contact : name

Add a column to your result: contact : internalId

This should give you a set that your script can iterate through.

Lez Yeoh
  • 340
  • 1
  • 2
  • 13
1

You should be able to create a vendor or customer search and the search should return the company/name or more details. Just select as a filter or column: Contact fields... Company

Perhaps something like this (Running from within the record):

var filters = [];
var columns = [];

filters.push(new nlobjSearchFilter('internalidnumber', null, 'equalto', [nlapiGetRecordId()]));
columns.push(new nlobjSearchColumn('entityid', 'contact', null));

var results = nlapiSearchRecord(nlapiGetRecordType(), null, filters, columns);
Adolfo Garza
  • 2,966
  • 12
  • 15