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
bantonbanton 

Date create question

I am having trouble creating a contact object that includes a Birthdate. Whenever I add the Brithdate field it does not insert the entry into SalesForce. I assume that it has something to do with the way that I am defining the current date. Below is the code:

$birthdate = date('m/d/Y');
....
'Birthdate' => $birthdate,
....

Any help would be appreciated.
Park Walker (TAGL)Park Walker (TAGL)
Try formatting your date using this format:

$birthdate = gmdate("Y-m-d\TH:i:s\Z",$mydate);
bantonbanton
That doesn't seem to do the trick either. I am also having trouble creating an object with a double data type. Could these two things be related?
dhruvadhruva
Are you specifying the Field type? xsd:date, xsd:double, etc?
bantonbanton
Sorry for the stupid question, but how do I go about doing that? I am currently sending the request like this:

$FIELDS=array(
'type' => 'Account',
'AnnualRevenue' => $a,
'Name' => utf8_encode("testAccount"));
$result=$client->create($FIELDS);

Where $a is a double.
Park Walker (TAGL)Park Walker (TAGL)
What is the error message that is being returned?
dhruvadhruva
Not 100% sure, but try:
'AnnualRevenue' => [$a,'xsd:double'],
'Name' => [utf8_encode("testAccount"),'xsd:string']

Maybe if the second part is not specified, it defaults to a string.
Park Walker (TAGL)Park Walker (TAGL)
If you are using the PEAR libraries try setting the global variable $SOAP_RAW_CONVERT = true; before you make the call.

At least some versions of the library us this flag in the SOAP/Base module to decide whether to attempt to parse doubles, base64 and date values, or leave them as strings.

You'll need to make sure that your double has a decimal part - even if it's .0 - in order for this to work. i.e. $foo = 12.0
mellyhedgesmellyhedges

Thank you for this suggestion. All those who are experiencing formatting problems with dates (using PEAR), in my case inserting an ActivityDate for a in Activity History, the suggestion above worked. That is, setting the $SOAP_RAW_CONVERT = true;

What I did was add that line to the \SOAP\Base.php page, and then my line of code looked like the following:

$xddate = gmdate('Y-m-d\T13:00:00\Z');

Fields = array('type'=>task, 'WhoId=>$exist_id,'Subject'=>$finfo,'ActivityDate'=>$xddate);

 

stathostatho
I have the same problem, but i'm using NuSOAP, PEAR::SOAP is two heavy for what i intend to do with.

error : INVALID_TYPE_ON_FIELD_IN_RECORD


--------------------------code-----------------------------
$event = new SObject ('Event', null , array('ActivityDate' => '21/03/2006',
                                                'IsAllDayEvent' => true,
                                                'IsRecurrence' => false,
                                                'OwnerId' => $id,
                                                'Type' => 'Call',
                                                'WhoId' => $WhoId,
                                                'ShowAs' => 'Busy' ) ) ;

    $createEventRes = $sfdc->create($event);

---------------------------/code---------------------------

I tried : gmdate(), date() in a lot of different format.

Thanks :)