1

I am trying to pull cases based on a custom field, however whenever I try this I get the following error:

SearchCustomField is an abstract type and cannot be instantiated

I have already looked through a few previous posts on here and this code previously worked for someone else: Search Customer by custom field in Netsuite

$NSservice = new NetSuiteService();
$NSservice->setSearchPreferences(false, 10);

$cs = new CustomerSearch();
$csb = new CustomerSearchBasic();

$domain = new SearchCustomField();
$domain->internalId = '620';
$domain->searchValue = '8260';
$domain->operator = 'is';

$scfl = new SearchCustomFieldList();
$scfl->customField = array($domain);
$csb->customFieldList = $scfl;
$cs->basic = $csb;

$request = new SearchRequest();
$request->searchRecord = $cs;

$searchResponse = $NSservice->search($request);
mkrieger1
  • 19,194
  • 5
  • 54
  • 65

1 Answers1

0

Looking at the latest schema searching SupportCases by a custom field is definitely supported.

Looking at your code, the internalId of your custom field looks incorrect. Normally, the internalId specified in your search is a string, not a number. It will start with the prefix cust.

FWIW the PHP Toolkit has a good bunch of bugs. You may want to consider using the ruby library which supports this operation and is well supported by the open source community.

iloveitaly
  • 2,053
  • 22
  • 21
  • The internalId is definately correct as ive printed the response from another request to double check it. I will have a look at the ruby libary – Josh Whiddett Sep 27 '19 at 12:06
  • 1
    At some point the `internalId` and `scriptId` were swapped. Depending on which API version you are using the wrong ID could be in the replace. I would look for an ID with a prefix of `cust`. – iloveitaly Sep 29 '19 at 14:40