Netsuite PHP API - 通过电子邮件查找客户

时间:2012-06-14 23:29:42

标签: php soap netsuite

我正在尝试通过电子邮件搜索客户。 Netsuite api文档没有多大帮助。感谢我能得到的任何帮助。谢谢。

    global $myNSclient;
$email = "myemail";
$item = new nsComplexObject('SearchStringField');
$item->setFields(array( 'searchValue' => $email, 'operator' => 'is'));
$search = new nsComplexObject('ContactSearchBasic');
$search->setFields($item);
$myNSclient->setSearchPreferences(false, 10);
$searchResponse = $myNSclient->search($search);

2 个答案:

答案 0 :(得分:1)

我有很多白发试图自己解决这个问题。

以下是从他们的电子邮件中获取联系人(不同于Netsuite中的客户,两者都是本机数据类型)的代码。对于客户而言,它将非常相似。

$service = new NetSuiteService();
$service->setSearchPreferences(false, 20);

$recordRef = new RecordRef();
$recordRef->internalId = '-6'; //Internal ID for a customer is -2, contact is -6

$contactSearch = new ContactSearch(); //use CustomerSearch() for a customer
$contactSearchBasic = new ContactSearchBasic();//SearchRecordBasic
$contactSearchBasic->email = new SearchStringField();
$contactSearchBasic->email->searchValue = 'someone@somewhere.com';
$contactSearchBasic->email->operator = SearchStringFieldOperator::is;
$contactSearch->basic = $contactSearchBasic;

$searchRequest = new searchRequest(); //% contains a searchRecord
$searchRequest->searchRecord = $contactSearch; 

$searchResponse = $service->search($searchRequest);

答案 1 :(得分:0)

前段时间我在我的博客上发布了一些示例代码。我认为它应该回答你的问题:

See the post

除此之外,我认为你会想要使用类型为“CustomerSearchBasic”的nsComplexObject。希望有所帮助!