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

PEAR::SOAP issue updating ActivityDate for a Task

So, I am have a helluva time updating this pesky column; ActivityDate. I have read the discussions and have figured out that it's how the string is getting converted; however, I am having issues doing this with the old school PEAR::SOAP. I took someone's advice and changed the $Globals['SOAP_RAW_CONVERT'} = true. However, that worked for the date, but then would not properly convert my string values.
All I want to do is insert an ActivityDate for a new task. It seems liked I have tried everything, and have come very close, but it ultimately messes something else up.
Has anyone....(your grandmother, niece, dog, or postal carrier) been able to come up with a workable solution for this problem?
This may or may not be useful... I have a PHP5 native client (rather than PEAR) that is successfully creating (I've not tried updating) tasks with an activity date set in an associative array like this:

$task = array(
'WhoId' => $contactid,
'Description' => utf8_encode("$comment"),
'Subject' => "Personal data updated",
'Status' => 'Completed',
'OwnerId' => $perpid,
'ActivityDate' => gmdate(DATE_ISO8601)

The array is then turned into a Task SoapVar and submitted to SF like this:

$taskvar = new SoapVar((object)$task, SOAP_ENC_OBJECT, 'Task', '', 'Task', '');
$res = $this->salesforce->create((object)array('sObjects' => $taskvar));

The DATE_ISO8601 constant is available in PHP >= 5.1.1, but you could look it up to check the exact format it uses if you're using an older version. I don't know how much of this is applicable to your problem, but at least you can look at this as something that works!

I'm actually in the middle of converting everything to use the SF PHP5 library (from my own PHP5 class), and I suspect the syntax there may be easier still.
Park Walker (TAGL)Park Walker (TAGL)
I think I mentioned this in another post, but if you are using SOAP_RAW_CONVERT the library will attempt to convert every string to a number, date or hex value. The trick to making this work is to make sure that each string has the correct characteristics for they type (don't you love untyped languages?).

The first step is to use SOAP_RAW_CONVERT dynamically: don't set it someplace in your code and leave it on. Just set it before you make a call that has a date value in it and then set it back to false after the call. Next, if you find that it's converting a string to something else you need to make sure the value doesn't look like something else. Adding a space to the end of  the value should work. Similarly, to get a double, add '.0' to the end of a numeric value.

If you have a choice, look to moving to PHP 5. The soap library is much better and much faster.


Thanks Park, that worked! :-)

I do agree with moving to PHP 5, and planning to do so in the next month or the meantime, I had to get this piece working.