Confusing SalesForce error - php

I'm using the SalesForce PHP Toolkit and getting a connection just fine. But when I use any of the example code - see here
INVALID_FIELD: No such column '' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
I might just be struggling to find the answer because Google won't let me search for ''
The environment is CentOS 6 with PHP 5.3.

I just created an account here to answer this question. It took me all day long to find out this bug in PHP Toolkit. The problem is caused by the "fieldsToNull" property. I read an approx. solution here that gave me an idea where to look for the solution.
So a correct example would be:
$fields = array('LastName' => 'Doe');
$sObject = new SObject();
$sObject->fields = $fields;
$sObject->fieldsToNull = NULL;//this is the solution! :)
$sObject->type = 'Contact';
Then, proceed as usual with the remaining part of the examples of the PHP Toolkit. It worked fine with my Partner WSDL+Developer SF Account.
Hope it helps!

Related

Magento - setRelatedLinkData() only saves one link

i'm currently working on a little extension to make it possible to adopt related products of a group product on its associated products.
It work really fine, with the exception, that only the last of the 19 related product is saves and written to the database.
I've checked my source code over and over, even with my team collegue - the code seems to be correct.
In the following i've posted the snippet with the essential parts and i hope that anyone can give me a hint or an advice to solve this problem.
Best regards
Markus
$supplyList =$product->getRelatedProductIds();
$associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
$params = array();
$_associatedProduct = Mage::getModel('catalog/product');
$prodCount=0;
foreach($supplyList as $sup)
{
$params[$sup] = array('position'=>$prodCount);
$prodCount++;
}
foreach($associatedProducts as $prod)
{
$_associatedProduct
->load($prod->getId())
->setRelatedLinkData($params)
->save();
}
following an update for the problem mentioned in the first post.
Today it worked as it should, without changes made by myself or my collegue.
I'm not sure what the cause of the problem was (caches are disabled since last Monday) and the source was already correct implemented.
It works now and this post is solved, sadly without a solution.
best regards

PHRets using POST

I'm using PHRets and trying to return some search results. Below is the code, which is very basic and should work:
include('../include/common.php');
include('../classes/phrets.php');
$rets = new phRETS();
$connect = $rets->connect(RETS_LOGIN_URL, RETS_USERNAME, RETS_PASSWORD);
if($connect){
$search = $rets->SearchQuery('PROPERTY', 'RES', '((COUNTY=Dallas))', array('LIMIT'=>20));
print_r($rets->Error());
echo $rets->TotalRecordsFound($search);
$rets->Disconnect();
}else{
$error = $rets->Error();
print_r($error);
}
When I run the page, I receive the following error:
Array ( [type] => rets [code] => 20203 [text] => The request limit is too large for a GET. Please use the POST method to submit your search. ) 0
I don't see a parameter to force PHRets to send the request as a POST. Will this require a hack of the class, or am I missing something?
Thanks
EDIT: I just heard back from the developer. It's not supported at this time. Perhaps a less-busier person should clone it and work on that.. :) Anyway, if anyone has already has modified the code to make this work, let me know, please.
Get the latest phRETS version which supports POST method from here and replace with your old phrets.php.
then you need to add an extra line to the script
$rets->SetParam('use_post_method', true);
Note: By default it will be GET method.
I've published an updated version supporting POST searches available at https://github.com/nathanklick/PHRETS or via composer by adding "nathanklick/phrets": "1.0.2" to your composer.json file.

Highrise API Returning Error Code 500

I am attempting to use the PHP Wrapper for the Highrise API located here:
https://github.com/ignaciovazquez/Highrise-PHP-Api
I need to set a custom field for a HighrisePerson object. According to the code this should be pretty straightforward...
$person->setCustomField("Field Name", $value); // Pulled almost straight out of the documentation
Unfortunately when I try to save this back to highrise using $person->save(); I get the following error:
Uncaught exception 'Exception' with message 'API for Person returned Status Code: 500 Expected Code: 200'
So the error isn't in the code... Highrise just isn't accepting the custom field. Any ideas as to why this is?
In order to use 37signals throught Highrise-PHP-Api, you should provide an account name and access token;
$hr = new HighriseAPI();
$hr->setAccount("accountname");
$hr->setToken("token");
and then you can execute your other functions
$person->setCustomField("Field Name", $value);
If you carefully look at tests for this api, you will see;
if (count($argv) != 3)
die("Usage: php users.test.php [account-name] [access-token]\n");
Ok... I figured it out...
In the API the following:
$person->setCustomField("Field Name", $value);
creates a new custom field within Highrise. So if there isn't already a custom field named "Field Name" it would create it. If that field already exists, it returns the 500 error.
To the best of my knowledge there's no way to set the value of an existing field using that wrapper. You can only create new fields, which is kind of jank.
I found a fork off that wrapper that's working pretty well for me. It's hosted here: https://github.com/AppSaloon/Highrise-PHP-Api
The usage in this one is confusing and took me a while to figure out.
Basically you want to do a search for all the custom fields in Highrise. Once you find the one you want, you assign it the requisite value... So the code looks like this:
// Load up all the custom fields out of Highrise
$cfields = $highrise->findAllCustomfields();
// Search each custom field until we find the "Field Name" one. When we do, add it to our Highrise Person.
foreach ($cfields as $c) {
if ($c->getSubjectFieldLabel() == "Field Name")
{
// Assign that custom field to the person
$highrisePerson->addCustomfield($c, "Field Value");
}
}
I hope this helps someone else down the road who runs into the same issue. I discovered the forked PHP wrapper from another Stack Overflow question, but they were never able to get custom fields to work either.

Modifying budget of an AdWord Campaign by using API

I am implementing adword api version 201306 in one of my project. I am able to fetch the details of a campaign but unable to retrieve the budget details.
My goal is to access the budget details and modify them. I am using PHP library and request to all of you a piece of code written in php.
Any help would be highly appreciated.
Thanks,
Pramod
I found the solution and here is the way you need to go out - -
First you need to pass out the field 'BudgetId' in Campaign Service selector for CampaignStats.
Now you can use following code - -
$budgetService = $user->GetService('BudgetService', ADWORDS_VERSION);
$bm = new Money('10000000');
$campaign->budget->amount = $bm;
$boperation = new BudgetOperation();
$boperation->operand = $campaign->budget;
$boperation->operator = 'SET';
$budgetService->mutate($boperation);
Yes, I agree that this help is very less. Do let me know if anyone face any issue OR need more help.
Regards,
Pramod

Search issue in Jira

I am looking for a way to search issue based on summary in Jira.
There are couple of functions to search issue, the one i need is "getIssuesFromTextSearchWithProject" but when i use it, it does not return issues just from that project but returns related issues from all projects.
Any ideas? I am doing this in PHP.
$result = $soap->getIssuesFromTextSearchWithProject($authtoken,"PROJECT_NAME", "Search String",10);
My Fault :
Project name needs to be array of projects :(
So this worked :
$projects = array("PROJECT_NAME");
$result = $soap->getIssuesFromTextSearchWithProject($authtoken,$projects, "Search String",10);

Categories