function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
webdbprojectwebdbproject 

How to use the fieldsToNull on PHP?

I am trying to do an update a field to empty string using fieldsToNull, but it never works.

The following is the code:

  $fieldsToUpdate = array('Id'=>$ID,'Test__c'=>NULL);
  $sObject = new SObject();
  $sObject->fieldsToNull = $fieldsToUpdate;

  $rs = $mySforceConnection->update(array($sObject));

Please help...
 
Thanks
Tran ManTran Man
The current version doesn't support this.  I'll email you a version (which will become v1.1) that another person is testing out that should have this implemented.
webdbprojectwebdbproject

Do you know when you will have the version? Since I am on a deadline to implement this.

 Thanks

Tran ManTran Man
I'll try to get you something by COB.  I want to test it first.
Tran ManTran Man
Actually I lied, you should be able to use the current toolkit to do this:  :smileyhappy:

Pass in the column name you want to null out like so:

Code:
$sObject->fieldsToNull = array('FirstName', 'LastName');

 Let me know if that works.


webdbproject wrote:

Do you know when you will have the version? Since I am on a deadline to implement this.

 Thanks





Message Edited by Tran Man on 05-23-2006 02:52 PM

webdbprojectwebdbproject

It doesn't work and I probably wrong:

   The following is the code. I want to set Name_c custom field to empty string.

   $sObject = new SObject();
   $sObject->fields = $fieldsToUpdate;
   $sObject->fieldsToNull = array("Name__c");
   $sObject->type = 'Lead';
   $acct = $mySforceConnection->update(array($sObject));

Thanks

Message Edited by webdbproject on 05-23-2006 04:26 PM

Tran ManTran Man
What is the error?
Can you print out $acct? 

print_r($acct);
webdbprojectwebdbproject

It shows

stdClass Object ( [errors] => [id] => 00Q3000000C4EtcEAF [success] => 1 )

Thanks

 

webdbprojectwebdbproject
Any help please?
Tran ManTran Man
I sent you a private e-mail yesterday.  Essentially, I need some info to help you debug.

Echo your SOAP messages by doing the following.
echo $mySforceConnection->getLastRequest;
echo $mySforceConnection->getLastRequestHeaders;
echo $mySforceConnection->getLastResponse;
echo $mySforceConnection->getLastResponseHeaders



webdbprojectwebdbproject

Hi Sorry for not checking my email

I got nothing after echo

$mySforceConnection->getLastRequest:
$mySforceConnection->getLastRequestHeaders:
$mySforceConnection->getLastResponse:
$mySforceConnection->getLastResponseHeaders:

Thanks and I will check your response daily

Tran ManTran Man
Did you echo like this?

echo $mySforceConnection->getLastRequest;


webdbprojectwebdbproject

Yes, I echo like this

echo $mySforceConnection->getLastRequest;
echo $mySforceConnection->getLastRequestHeaders;
echo $mySforceConnection->getLastResponse;
echo $mySforceConnection->getLastResponseHeaders;

and get nothing. Thanks...

Tran ManTran Man
Perhaps it is blowing up before executing update, try putting a try/catch statement surrounding your code.

try {
// your code
} catch (Exception $e) {
  print_r($e);
}

Also, I didn't see in your second snippet of code where you specified an Id.




jessesjesses
Where are we on resetting values to null using the PHP api? Still doesn't seem to work:

The object I call update() on:

SObject Object
(
[Id] => 0035000000KSZUqAAP
[type] => Contact
[fields] => Array
(
[id] => 0035000000KSZUqAAP
[FirstName] => Jesse
[LastName] => Snyder
)

[fieldsToNull] => Array
(
[0] => Preferred_days_for_meetings__c
[1] => Best_time_of_day__c
)

)
The result:

stdClass Object
(
[errors] =>
[id] => 0035000000KSZUqAAP
[success] => 1
)

The fields still hold their previous value (are not null)


TimoRTimoR

Any update on this. It still does not seem to work ?

Thanks.

jessesnyderjessesnyder
Hi TimoR,

You're right, it's still not working. I have an outstanding support ticket on this. I spent the better part of a day studying the toolkit code, and it looks to me like they just didn't implement the fieldsToNull part of the API. :-)  They have not exactly thrown themselves into fixing this either - no work on my request for many weeks, despite my frequent pestering. I'll try to remember to keep you posted if there's any progress, but I would also encourage you to post your own support request, since there may be some power in numbers.

Jesse
Tran ManTran Man
Hi, your e-mail address doesn't work.  Please shoot me an e-mail at ntran@salesforce.com and I'll send you a private version to test.

- Nick
ricardricard
Hi Nick,
Could you send the test version to me as well, I need to use fieldsToNull on PHP.

Thanks,
jessesnyderjessesnyder
Hi Ricard,

I can verify that Nick's modifications fixed the problem. Enjoy!

Jesse
aztronautaztronaut
Nick,
I also need the version of the toolkit with support for fieldsToNull.
Mike @ PartnersMike @ Partners
Did you ever get the 'fieldsToNull' to work. If so, could you let me know? I can't get it to work.
Thanks,
Mike
jessesnyderjessesnyder
As of 10/2006 or so, fieldsToNull() required a patch to one of the toolkit classes. This patch may be in the newest downloadable version of the php toolkit, but I'm not sure. Nick Tran wrote the fix and provied it to me a few months back It was going to be incorporated into the main trunk, so it may be included in the latest version. Check the implementation of the update() function in SforceBaseClient - if it instantiates any SoapVar objects, you've to the unpatched version.
Tran ManTran Man
The latest 1.0.6 toolkit has the fix.