Using the latest NetSuite PHP Toolkit v2012_2, how can I get the contents of lists and in particular custom lists?
For example, we have a custom list with options for how the customer heard about us. We modify this list from time to time. When a visitor to our site gets to our registration screen we’d like to pull in from NetSuite the list items for the custom list with id 3 (along with each list item’s id) so we can fill a drop-down box for use when creating a contact in NetSuite. This way we can maintain a single list in NetSuite and it will always be current in the website.
Credit and thanks to Saqib!
For reference, here is an example of the code that is now working:
$service = new NetSuiteService();
$service->setSearchPreferences(false, 20);
$recordRef = new RecordRef();
$recordRef->internalId = 1;
$searchField = new SearchMultiSelectField();
$searchField->operator = "anyOf";
$searchField->searchValue = $recordRef;
$search = new CustomListSearchBasic();
$search->internalId = $searchField;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
var_dump($searchResponse);
die();
Perhaps http://tellsaqib.github.com/NSPHP-Doc/ could help you in coding it yourself.
Related
I'm currently using square/connect-php-sdk createOrder to create a Square Order.
$api_config = new SquareConnect\Configuration();
$api_config->setAccessToken($access_token);
$api_config->setHost($host);
$api_client = new SquareConnect\ApiClient($api_config);
$apiInstance = new SquareConnect\Api\OrdersApi($api_client);
$orderRequest = new SquareConnect\Model\CreateOrderRequest();
$orderRequest->setIdempotencyKey(uniqid());
$order = new SquareConnect\Model\Order();
$money = new SquareConnect\Model\Money();
$money->setAmount(intval(500))
->setCurrency("USD");
$line_item = new SquareConnect\Model\OrderLineItem();
$line_item->setCatalogObjectId(<square item id>)
->setQuantity("1")
->setBasePriceMoney($money);
$line_items[] = $line_item;
$order->setLineItems($line_items);
$orderRequest->setOrder($order);
$result = $apiInstance->createOrder($location_id, $orderRequest);
This returns an Order ID (along with other order data) which I store locally.
I then process a credit card using the Square Payment Form: https://developer.squareup.com/docs/payment-form/payment-form-walkthrough
This gives me a nonce which I then send with the Order ID and the price.
$apiInstance = new SquareConnect\Api\PaymentsApi($api_client);
$paymentRequest = new SquareConnect\Model\CreatePaymentRequest();
$paymentRequest->setIdempotencyKey(uniqid());
$paymentRequest->setLocationId($location_id);
$money = new SquareConnect\Model\Money();
$money->setAmount(intval($total_cost))
->setCurrency("USD");
$paymentRequest->setAmountMoney($money);
$paymentRequest->setOrderId($sq_order_id);
$paymentRequest->setSourceId($nonce);
$result = $apiInstance->createPayment($paymentRequest);
This gives me a Payment ID (along with other payment data).
On the Square Dashboard, I am able to see the transaction in the Transactions section, but the Orders section of the dashboard is empty.
My question is How do I get it to show in the Orders section?
In order for the order to show up in your dashboard you need to do two things:
1. Pay for the order (it sounds like you did this part)
2. Include a fulfillments parameter in the CreateOrder request: https://developer.squareup.com/docs/orders-api/order-ahead-usecase#add-fulfillment-information-to-make-a-pickup-order
I'm trying to add company name when I add a new customer, anyone can help?
By the way, where is the documentation for quickboos-php devkit , I can't find it as well.
The below is the code:
$CustomerService = new QuickBooks_IPP_Service_Customer();
//add basic info
$Customer = new QuickBooks_IPP_Object_Customer();
$Customer->setTitle($title);
$Customer->setGivenName($given_name);
$Customer->setMiddleName($middel_name);
$Customer->setFamilyName($family_name);
$Customer->setDisplayName($display_name);
// Phone #
$PrimaryPhone = new QuickBooks_IPP_Object_PrimaryPhone();
$PrimaryPhone->setFreeFormNumber($primary_phone);
$Customer->setPrimaryPhone($PrimaryPhone);
// Mobile #
$Mobile = new QuickBooks_IPP_Object_Mobile();
$Mobile->setFreeFormNumber($mobile);
$Customer->setMobile($Mobile);
// Bill address
$BillAddr = new QuickBooks_IPP_Object_BillAddr();
$BillAddr->setLine1($bill_address);
$BillAddr->setCity($bill_city);
$BillAddr->setCountrySubDivisionCode($bill_state);
$BillAddr->setCountry($bill_country);
$BillAddr->setPostalCode($bill_zip_code);
$Customer->setBillAddr($BillAddr);
// Shipping address
$ShipAddr = new QuickBooks_IPP_Object_ShipAddr();
$ShipAddr->setLine1($address_1);
$ShipAddr->setLine2($address_2);
$ShipAddr->setCity($city);
$ShipAddr->setCountrySubDivisionCode($province);
$ShipAddr->setCountry($country);
$ShipAddr->setPostalCode($postal_code);
$Customer->setShipAddr($ShipAddr);
$customer_id = $CustomerService->add($Context, $realm, $Customer);
The list of available fields for Customer objects is on Intuit's website:
https://developer.intuit.com/docs/api/accounting/customer
You're probably looking for:
CompanyName:
optional
String, maximum of 50 chars, filterable, sortable, default is null
The name of the company associated with the person or organization.
Unsurprisingly, there's a couple of corresponding methods:
$Customer->setCompanyName($v);
$v = $Customer->getCompanyName();
According to this: https://developers.facebook.com/docs/marketing-api/reference/custom-audience#Reading the following piece of code should return the custom audiences related to my ads account. It does return an array of the objects, but the only fields populated on this is the ID (everything else, including its name, is null).
$account = new AdAccount(<ADS_ACCOUNT_NO>);
$audiences = $account->getCustomAudiences();
I've just found the answer and it is that you need to read() each object in order to obtain the full details.
Something like this should work fine:
$account = new AdAccount(<ADS_ACCOUNT_NO>);
$audiences = $account->getCustomAudiences();
$audiencesObjects = $audiences->getObjects();
foreach($audiencesObjects as $audienceObj) {
$data = $audienceObj->read(['name', 'rule'])->getData();
print $data['name'];
}
I can record a contact from php toolkit, now i should attach contact to an existing opportunity, is this possible with the same way as adding custom field?
$records[0] = new stdclass();$records[0]->FirstName = 'Irish';
$records[0]->LastName = 'Paul';
$records[0]->Phone = '(510) 555-5555';
$records[0]->myCustomField__c= 'value1; value2';
Now to attach this with opportunity, how should i do?
Thank you
I have a saved search in Netsuite that's only criteria is "Type is Item Group" and I am trying to use the Soap API SuiteTalk to retrieve its results through PHP.
Here's the function I'm using:
function getSavedSearch($ns_client, $search_id, $search_type, $page_size = 1000) {
$searchItem = array();
$searchItem['savedSearchId'] = $search_id;
$search = new nsComplexObject($search_type);
$search->setFields($searchItem);
$ns_client->setSearchPreferences(false, $page_size);
return $ns_client->search($search);
}
I try calling it with the search's internalId and the type 'ItemSearchAdvanced' but that returns a search with 0 records.
If I change the type to 'ItemSearchBasic' it seems to ignore the search criteria and I get every item record in the system (not limited to item groups).
I am able to use the same function to retrieve the results of other saved searches such as as "Transaction Search" using the type "TransactionSearchAdvanced".
I suspect there is a different search type I should be using but I can't find any references to what it should be.
This code uses an older version of the Toolkit.
The 2013_1 version is much, much better and easier to use. Also, be careful which endpoint the Toolkit points toward, as older versions, like 2009_2 are no longer supported.
The code when using the 2013_1 version of the Toolkit is simple:
$service = new NetSuiteService();
$search = new ItemSearchAdvanced();
$search->savedSearchId = "XX"; //replace with your internal ID
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);