I'm using php toolkit for netsuite 2013.1. Here my code:
require_once("2013_1/NetSuiteService.php");
$service = new NetSuiteService();
$getCustomizationType = "itemCustomField";
$getCustomizationIdRq = new GetCustomizationIdRequest();
$getCustomizationIdRq->customizationType = new CustomizationType();
$getCustomizationIdRq->customizationType->getCustomizationTypeSpecified=true;
$getCustomizationIdRq->customizationType->getCustomizationType = GetCustomizationType::itemCustomField;
$getCustomizationIdResult = $service->getCustomizationId($getCustomizationIdRq, false);
And the result:
No such operation 'getCustomizationId'
So I think this function is missing? Function link
Here ya go...
$NSservice = new NetSuiteService();
$cT = new CustomizationType();
$cT->getCustomizationType = "customRecordType"; // or itemCustomField or whatever
$gcIdR = new GetCustomizationIdRequest();
$gcIdR->customizationType = $cT;
$gcIdR->includeInactives = false;
$readResp = $NSservice->getCustomizationId($gcIdR);
print_r($readResp);
Related
I have PHP code for Advanced Search items in NetSuite,
but I don't know how I can combine to my search - filtering by item name.
My code is:
$service = new NetSuiteService($config);
$service->setSearchPreferences(true, $page_size, true);
$savedSearchId = '###';
$searchAdvanced = new ItemSearchAdvanced();
setFields($searchAdvanced, array('savedSearchScriptId'=>$savedSearchId));
$request = new SearchRequest();
$request->searchRecord = $searchAdvanced;
$results = $service->search($request);
I want to combine a criteria
Here's sample code I found to get inventory details using Item internal id as a filter. You can reference Suite Answer 90401, 37585, and 25066.
<?php
require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
// formulate the criteria
$itemRecord = new RecordRef();
$itemRecord--->internalId = 140;
$itemMultiSelect = new SearchMultiSelectField();
$itemMultiSelect->operator = 'anyOf';
$itemMultiSelect->searchValue = $itemRecord;
$itemSearchBasic = new ItemSearchBasic();
$itemSearchBasic->internalId = $itemMultiSelect;
$criteria = new ItemSearch();
$criteria->basic = $itemSearchBasic;
// formulate the resulting columns
$searchRowBasic = new ItemSearchRowBasic();
$searchRowBasic->itemId = new SearchColumnStringField(); // Item Name/Number in UI
$searchRowBasic->internalId = new SearchColumnSelectField(); // Internal ID in UI
$searchRowBasic->location = new SearchColumnSelectField(); // Location (Main section of Inventory Item) in UI
$searchRowBasic->inventoryLocation = new SearchColumnSelectField(); // Location column in Locations tab (Inventory Item) in UI
$searchRowBasic->locationQuantityOnHand = new SearchColumnDoubleField();// Quantity on Hand column in Locations tab (Inventory Item) in UI
$columns = new ItemSearchRow();
$columns->basic = $searchRowBasic;
// item search advanced
$search = new ItemSearchAdvanced();
$search->criteria = $criteria;
$search->columns = $columns;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
if (!$searchResponse->searchResult->status->isSuccess) {
echo "SEARCH ERROR";
} else {
echo "SEARCH SUCCESS, records found: " . $searchResponse->searchResult->totalRecords ;
}
?>
I am using nopcommerce 3.5. I have added plugin of UPS of TransitInTime and Rate API. I want to get rates by calling UPS Rate API. I want all Rates in dropdown on page load.
So for the first I am using test application using webservices of RateWebReference and in which I get only one Rate but I want Rates for all shipping option.
Here is my code of RateWSClient.cs
RateService rate = new RateService();
RateRequest rateRequest = new RateRequest();
UPSSecurity upss = new UPSSecurity();
UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken();
upssSvcAccessToken.AccessLicenseNumber = "CC....";
upss.ServiceAccessToken = upssSvcAccessToken;
UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken();
upssUsrNameToken.Username = "gi..";
upssUsrNameToken.Password = "Ch..";
upss.UsernameToken = upssUsrNameToken;
rate.UPSSecurityValue = upss;
RequestType request = new RequestType();
String[] requestOption = { "Rate" };
request.RequestOption = requestOption;
rateRequest.Request = request;
ShipmentType shipment = new ShipmentType();
ShipperType shipper = new ShipperType();
shipper.ShipperNumber = "A65V88";
RateWSSample.RateWebReference1.AddressType shipperAddress = new RateWSSample.RateWebReference1.AddressType();
String[] addressLine = { "", "", "" };
shipperAddress.AddressLine = addressLine;
shipperAddress.City = "";
shipperAddress.PostalCode = "30076";
shipperAddress.StateProvinceCode = "GA";
shipperAddress.CountryCode = "US";
shipperAddress.AddressLine = addressLine;
shipper.Address = shipperAddress;
shipment.Shipper = shipper;
ShipFromType shipFrom = new ShipFromType();
RateWSSample.RateWebReference1.AddressType shipFromAddress = new RateWSSample.RateWebReference1.AddressType();
shipFromAddress.AddressLine = addressLine;
shipFromAddress.City = "";
shipFromAddress.PostalCode = "30076";
shipFromAddress.StateProvinceCode = "GA";
shipFromAddress.CountryCode = "US";
shipFrom.Address = shipFromAddress;
shipment.ShipFrom = shipFrom;
ShipToType shipTo = new ShipToType();
ShipToAddressType shipToAddress = new ShipToAddressType();
String[] addressLine1 = { "", "", "" };
shipToAddress.AddressLine = addressLine1;
shipToAddress.City = "";
shipToAddress.PostalCode = "92262";
shipToAddress.StateProvinceCode = "";
shipToAddress.CountryCode = "US";
shipTo.Address = shipToAddress;
shipment.ShipTo = shipTo;
CodeDescriptionType service = new CodeDescriptionType();
//Below code uses dummy date for reference. Please udpate as required.
service.Code = "02";
shipment.Service = service;
PackageType package = new PackageType();
PackageWeightType packageWeight = new PackageWeightType();
packageWeight.Weight = "125";
CodeDescriptionType uom = new CodeDescriptionType();
uom.Code = "LBS";
uom.Description = "pounds";
packageWeight.UnitOfMeasurement = uom;
package.PackageWeight = packageWeight;
CodeDescriptionType packType = new CodeDescriptionType();
packType.Code = "02";
package.PackagingType = packType;
PackageType[] pkgArray = { package };
shipment.Package = pkgArray;
//Shipping Rate Chart
// ShipmentRatingOptionsType SRO = new ShipmentRatingOptionsType();
//SRO.RateChartIndicator = "";
//shipment.ShipmentRatingOptions= SRO;
//rateRequest.Shipment = shipment;
ShipmentRatingOptionsType SRO = new ShipmentRatingOptionsType();
SRO.NegotiatedRatesIndicator = "";
shipment.ShipmentRatingOptions = SRO;
rateRequest.Shipment = shipment;
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
Console.WriteLine(rateRequest);
RateResponse rateResponse = rate.ProcessRate(rateRequest);
Console.WriteLine("The transaction was a " + rateResponse.Response.ResponseStatus.Description);
Console.WriteLine("Total Shipment Charges " + rateResponse.RatedShipment[0].TotalCharges.MonetaryValue + rateResponse.RatedShipment[0].TotalCharges.CurrencyCode);
Console.ReadKey();
I have resolved this questions. So If you face this kind of problem don't forget to use
String[] requestOption = { "Shop" };
in place of
String[] requestOption = { "Rate" };
Then you will get rates for all shipping options.
Google added a new way to add sitelink extensions.
https://developers.google.com/adwords/api/docs/guides/extension-settings#add_ad_extensions
I added a bunch of them, but how do you delete them? I had 3 sitelinks on each campaign. I was able to remove a sitelink from the campaigns, but it removed all sitelinks from the campaigns. They are still in the + Extension list, but not associated with any campaigns.
function deleteSitelinks($sitelinks) {
$user = $this->getUser();
$campaignExtensionSettingService = $user->GetService('CampaignExtensionSettingService', ADWORDS_VERSION);
// first remove the sitelinks from the campaigns
$operations = array();
foreach ($sitelinks as $sitelink) {
$sfi = new SitelinkFeedItem();
$sfi->feedItemId = $sitelink->google_feed_item_id;
$campaignExtensionSetting = new CampaignExtensionSetting();
$campaignExtensionSetting->campaignId = $sitelink->campaign->google_id;
$campaignExtensionSetting->extensionType = 'SITELINK';
$extensionSetting = new ExtensionSetting();
$extensionSetting->extensions = array($sfi);
$campaignExtensionSetting->extensionSetting = $extensionSetting;
$operation = new CampaignExtensionSettingOperation();
$operation->operator = 'REMOVE';
$operation->operand = $campaignExtensionSetting;
$operations[] = $operation;
}
$result = $campaignExtensionSettingService->mutate($operations);
// now remove the sitelinks themselves
$feedItemService = $user->GetService('FeedItemService', ADWORDS_VERSION);
$operations = array();
foreach ($sitelinks as $sitelink) {
$sfi = new SitelinkFeedItem();
$sfi->feedId = $sitelink->google_feed_id;
$sfi->feedItemId = $sitelink->google_feed_item_id;
$operation = new FeedItemOperation();
$operation->operator = 'REMOVE';
$operation->operand = $sfi;
$operations[] = $operation;
}
$result = $feedItemService->mutate($operations);
return $result->value;
}
Ok I 'fixed' it by re-adding all the sitelinks that belong to that campaign immediately after deleting the target sitelink. I swear, this is the most retarded part of this API.
...
$result = $campaignExtensionSettingService->mutate($operations);
// now re-add the other sitelinks. the google API is removing/disassociating ALL sitelinks for whatever reason
$operations = array();
foreach ($sitelinks as $sitelink) {
$campaignSitelinks = array();
$siblings = Sitelink::find()->where(['campaign_id' => $sitelink->campaign_id])->andWhere(['not', ['id' => $sitelink->id]])->all();
foreach ($siblings as $sibling) {
$sfi = new SitelinkFeedItem();
$sfi->feedItemId = $sibling->google_feed_item_id;
$campaignSitelinks[] = $sfi;
}
$campaignExtensionSetting = new CampaignExtensionSetting();
$campaignExtensionSetting->campaignId = $sitelink->campaign->google_id;
$campaignExtensionSetting->extensionType = 'SITELINK';
$campaignExtensionSetting->extensionSetting = new ExtensionSetting();
$campaignExtensionSetting->extensionSetting->extensions = $campaignSitelinks;
// Create operation.
$operation = new CampaignExtensionSettingOperation();
$operation->operator = 'SET';
$operation->operand = $campaignExtensionSetting;
$operations[] = $operation;
}
$result = $campaignExtensionSettingService->mutate($operations);
// now remove all the sitelinks themselves
$feedItemService = $user->GetService('FeedItemService', ADWORDS_VERSION);
...
I'm currently working on a project with the MangoPay api (with PHP SDK) and I have some trouble with the PaymentDetails. The function below generate this key (when I call the MangoPay Create method on my PayIn object) :
payins_stdclass-direct_create
instead of :
payins_preauthorized-direct_create
The function I'm using :
<?php
private function createAuthorizationPayIn($authorization, $fees)
{
$payIn = new MangoPay\PayIn();
$payIn->CreditedWalletId = $this->adminWalletId;
$payIn->AuthorId = $this->adminUserId;
$payIn->PaymentType = "PREAUTHORIZED";
$PayIn->PaymentDetails = new MangoPay\PayInPaymentDetailsPreAuthorized();
$payIn->PaymentDetails->PreauthorizationId = $authorization->Id;
$payIn->DebitedFunds = new MangoPay\Money();
$payIn->DebitedFunds->Currency = $authorization->DebitedFunds->Currency;
$payIn->DebitedFunds->Amount = $authorization->DebitedFunds->Amount;
$payIn->CreditedFunds = new MangoPay\Money();
$payIn->CreditedFunds->Currency = $authorization->DebitedFunds->Currency;
$payIn->CreditedFunds->Amount = $authorization->DebitedFunds->Amount;
$payIn->Fees = $fees;
$payIn->ExecutionType = "DIRECT";
$payIn->ExecutionDetails = new MangoPay\PayInExecutionDetailsDirect();
$payIn->ExecutionDetails->SecureMode = "DEFAULT";
$payIn->ExecutionDetails->SecureModeReturnURL = "https://website.com";
$payIn = $this->mangoPayApi->PayIns->Create($payIn);
$authorization->payinId = $payIn->Id;
$authorization = $this->mangoPayApi->CardPreAuthorizations->Update($authorization);
return $payIn;
}
How can I create the right PaymentDetails object to create a preAuthorized PayIn ?
I have been able to successfully retrieve the unread emails from an Exchange 2010 inbox using php-ews API. However after I have fetched the emails, I want to set the IsRead property of the email to true, so that these messages do not appear the next time I fetch emails.
Anyone done this before ?
EDIT :
This is how I am trying to set the IsRead flag :
$message_id = ''; //id of message
$change_key = ''; //change key
$response = $ews->GetItem($request);
//print_r($response);exit;
if( $response->ResponseMessages->GetItemResponseMessage->ResponseCode == 'NoError' &&
$response->ResponseMessages->GetItemResponseMessage->ResponseClass == 'Success' ) {
$a = array();
$message = $response->ResponseMessages->GetItemResponseMessage->Items->Message;
$a['message_body'] = $message->Body->_;
$a['sender'] = $message->From->Mailbox->EmailAddress;
$a['subject'] = $message->ConversationTopic;
$data[] = $a;
//process the message data.
$messageType = new EWSType_MessageType();
$messageType->IsRead = true;
$path = new EWSType_PathToUnindexedFieldType();
$path->FieldURI = 'message:IsRead';
$setField = new EWSType_SetItemFieldType();
$setField->Message = $messageType;
$setField->FieldURI = $path;
$u = new EWSType_ItemChangeType();
$u->Updates = new EWSType_NonEmptyArrayOfItemChangeDescriptionsType();
$u->Updates->SetItemField = $setField;
$u->ItemId = new EWSType_ItemIdType();
$u->ItemId->Id = $message_id;
$u->ItemId->ChangeKey = $change_key;
$updatedItems = new EWSType_NonEmptyArrayOfItemChangesType();
$updatedItems->ItemChange = $u;
$updateMessenger = new EWSType_UpdateItemType();
$updateMessenger->ItemChanges = $updatedItems;
$updateMessenger->MessageDisposition = 'SaveOnly';
$updateMessenger->ConflictResolution = 'AutoResolve';
try {
$update_response = $ews->UpdateItem($updateMessenger);
}catch (Exception $e){
echo $e->getMessage();
}
}
When I run the file I get the following error :
An internal server error occurred. The operation failed.
After debugging for some time, I have concluded that the error happens at the curl_exec function in NTLMSoapClient.php file.
I dont know where to go on from here. Please help.
I've faced a similar issue when updating a calendar event and setting the IsAllDayEvent flag. This is the code that worked for me:
$ews = new ExchangeWebServices(...);
$request = new EWSType_UpdateItemType();
$request->ConflictResolution = 'AlwaysOverwrite';
$request->ItemChanges = array();
$change = new EWSType_ItemChangeType();
$change->ItemId = new EWSType_ItemIdType();
$change->ItemId->Id = $id;
$change->ItemId->ChangeKey = $changeKey;
$field = new EWSType_SetItemFieldType();
$field->FieldURI = new EWSType_PathToUnindexedFieldType();
$field->FieldURI->FieldURI = "calendar:IsAllDayEvent";
$field->CalendarItem = new EWSType_CalendarItemType();
$field->CalendarItem->IsAllDayEvent = true;
$change->Updates->SetItemField[] = $field;
$request->ItemChanges[] = $change;
$response = $ews->UpdateItem($request);
The biggest difference I see here is that you do $u->Updates->SetItemField = $setField;, whereas my code uses $u->Updates->SetItemField[] = $setField;.
I hope this helps.
Edit: You might have already seen this, but I based my code on the one from the php-ews wiki.
I tried everything including PathToExtendedFieldType and it doesn't work at the end code below worked for me
$ews = new ExchangeWebServices('red', 'red', 'red',ExchangeWebServices::VERSION_2007_SP1);
$request = new EWSType_UpdateItemType();
$request->SendMeetingInvitationsOrCancellations = 'SendToNone';
$request->MessageDisposition = 'SaveOnly';
$request->ConflictResolution = 'AlwaysOverwrite';
$request->ItemChanges = array();
// Build out item change request.
$change = new EWSType_ItemChangeType();
$change->ItemId = new EWSType_ItemIdType();
$change->ItemId->Id = $contact_id;
$change->ItemId->ChangeKey = $contact_change_key;
#$change->Updates = new EWSType_NonEmptyArrayOfItemChangeDescriptionsType();
#$change->Updates->SetItemField = array();
// Build the set item field object and set the item on it.
$field = new EWSType_SetItemFieldType();
$field->FieldURI = new EWSType_PathToUnindexedFieldType();
$field->FieldURI->FieldURI = "message:IsRead";
$field->Message = new EWSType_MessageType();
$field->Message->IsRead = true;
$change->Updates->SetItemField[] = $field;
$request->ItemChanges[] = $change;
$response = $ews->UpdateItem($request);
var_dump($response);
Well, i dont know how it is in php, but in C# there is another field, that must be set: IsReadSpecified = true.
email.IsRead = true;
email.IsReadSpecified = true;