php – 使用salesforce api将联系人与帐户联系起来

前端之家收集整理的这篇文章主要介绍了php – 使用salesforce api将联系人与帐户联系起来前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我是使用salesforce api的新手.我已经下载了saleforce / PHP工具包,并且能够从我服务器上的webform成功创建联系人和帐户.

要创建联系人,我正在执行以下操作:

$records[0] = new stdclass();
    $records[0]->FirstName = $FirstName;
    $records[0]->LastName = $LastName;
    $records[0]->Email = $Email;
    $records[0]->Phone = $Phone;
    $records[0]->MailingStreet = $MailingStreet;
    $records[0]->MailingCity = $MailingCity;
    $records[0]->MailingState = $MailingState;
    $records[0]->MailingPostalCode = $MailingPostalCode;
    $records[0]->MailingCountry = $MailingCountry;
    $records[0]->LeadSource = $LeadSource;

    $create = $mySforceConnection->create($records,'Contact');

要创建帐户,我正在执行以下操作

$records[0] = new stdclass();
    $records[0]->Name = $Name

    $create = $mySforceConnection->create($records,'Account');

任何人都可以给我一个简单的例子,说明如何将联系人与帐户相关联?

我在表单上有一个复选框,询问这是否是一个组织.如果用户选中此框,我想创建一个包含某些数据的组织帐户,并创建与某些数据的联系并将这两个数据相关联.

我并不是在寻找一个完整的工作实例,而是更多的只是让我指向正确的方向.

假设我有一个ID为001Z0000004XeWfIAK的帐户

我试过了

$records[0] = new stdclass();
    $records[0]->FirstName = $FirstName;
    $records[0]->LastName = $LastName;
    $records[0]->Email = $Email;
    $records[0]->Phone = $Phone;
    $records[0]->MailingStreet = $MailingStreet;
    $records[0]->MailingCity = $MailingCity;
    $records[0]->MailingState = $MailingState;
    $records[0]->MailingPostalCode = $MailingPostalCode;
    $records[0]->MailingCountry = $MailingCountry;
    $records[0]->LeadSource = $LeadSource;
    $records[0]->AccountId = '001Z0000004XeWfIAK';

    $create = $mySforceConnection->create($records,'Contact');

@ superfell

它返回这个:

Array
(
    [0] => stdClass Object
        (
            [errors] => Array
                (
                    [0] => stdClass Object
                        (
                            [message] =>  A Household Contact's account must be a household.
                            [statusCode] => FIELD_CUSTOM_VALIDATION_EXCEPTION
                        )

                )

            [id] => 
            [success] => 
        )

)

但我试图将联系人与orginization联系起来

联系人有一个AccountId字段.因此,下面的代码假定您在名为$accountId的变量中拥有帐户ID,而$resource [0]是您要关联的联系人.
$records[0]->AccountId = $accountId
$mySforceConnection->update($records)

我不太了解PHP,但我认为这将接近正确.

猜你在找的PHP相关文章