Question

I am creating customers for NetSuite from my application by using the NetSuite PHP SDK, version 2013_2.

This mostly works, but I can not set a status for new Customers. No matter what, the status will always be CUSTOMER-Won Customer, which I don't want. I can't find any documentation about this, so I basically tried whatever seemed to make sense and tried to understand the code of the SDK. Here are some of the things I tried:

$customer->entityStatus = 17;

$customer->entityStatus = new \RecordRef(array('internalId' => 17, 'type' => 'customer'));

$customer->entityStatus = new \RecordRef();
$customer->entityStatus->internalId = 17;

All of these are simply ignored. I tried different internal IDs (and of course, I made sure all of them exist in the system). I tried using strings ('17' instead of 17), but nothing helped.

Documentation has nothing about this either.

Here's my full working code:

    $ns = new \NS_NetSuiteService();
    $customer = new \Customer();
    $customer->companyName = $company->getName();
    $customer->entityStatus = 17;
    $customer->email = $user->getEmail();

    $request = new \AddRequest();
    $request->record = $customer;

    $res = $ns->add($request);
Was it helpful?

Solution

I always create the RecordRef first, then set the field. Seems to keep things in order for me:

$entityStatus = new RecordRef();
$entityStatus->internalId = 17;
$entityStatus->recordType = "customerStatus";

$customer->entityStatus = $entityStatus;

Or, take my example and shorten the code once you see it working this way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top