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
CotralLabWebDevCotralLabWebDev 

How to check a custom checkbox through SOAP API (in PHP)

Hi everyone,

I can't seem to set a custom checkbox to "true" using the SOAP API with PHP.

For years we have been creating tasks through PHP using the Salesforce SOAP API (enterprise.wsdl.xml). It works fine, but now we've added a custom ckeckbox to tasks (let's call it "CustomBox__c") that I need to check under some conditions.

Problem is : I added the new field to the task sent through the SOAP API, set it to "true", but it does not work. The task is created, no error is returned and "success == true", but the checkbox is not checked.

Here's the code I'm using :
$o_Task = new stdclass();
$o_Task->WhoId = /*  */
$o_Task->WhatId = /*  */
$o_Task->OwnerId = /*  */
$o_Task->Description = /*  */
$o_Task->Type = /*  */
$o_Task->Subject = /*  */
$o_Task->Status = /*  */
$o_Task->ActivityDate = /*  */

$o_Task->CustomBox__c = true;

$o_Response = $o_SforceConnection->create(array($o_Task), 'Task');
The only difference being "$o_Task->CustomBox__c = true;"

At this point, my question would be : Why does the checkbox not update, and what should I do to achieve this ?

I made a few tests and search but nothing seems to work :
  • I found a few references (forums and blogs, few month to few years old) saying that a custom field that is not a simple Text field, but a non-text field such as Number, Checkbox or Date needs an extra step consisting in adding a field to the task object in the form of "CustomBox__cSpecified = true" in order for the CustomBox__c field to be taken into account. Unfortunately, this does not work either : I get an error "Invalid field: no such column 'CustomBox__cSpecified' on entity 'Task' [...]". Plus, I could not find any reference of this ine the Salesforce documentation.
  • For testing purpose, we also tried to create a Workflow that check the box when my user creates a task : it works fine when the task is created manually through the web interface of Salesforce, but it seems the workflow is not executed when the task is created with PHP and the SOAP API (user creating the task is the same in both cases, and owner of the task is another admin)
Have you any idea that could help me solve this ?