简化记录类型 ID 链接

发布于 2024-11-09 14:46:02 字数 443 浏览 0 评论 0原文

通过 PHP 使用 Salesforce SOAP API 时,如果我有一个对象,该对象具有帐户的查找字段,并且帐户上的特定字段设置为外部 ID,我可以执行以下操作:

$sfBooking->fields['Account__r'] = "<type>Account</type>"
    . "<custom_account_id__c>"
    . utf8_encode($tboxBooking->client_id)
    . "</custom_account_id__c>";

这在以下情况下非常方便尝试链接记录而无需使用其 Salesforce ID。

我想知道在通过 API 设置对象的记录类型时是否可以使用类似类型的简写。如果可能的话,我想取消必须首先通过查询记录类型对象来获取记录类型 ID 的步骤。

When using the Salesforce SOAP API via PHP, if I have an object which has a look-up field to an account with a specific field on the account which is set up as an external id, I can do the following

$sfBooking->fields['Account__r'] = "<type>Account</type>"
    . "<custom_account_id__c>"
    . utf8_encode($tboxBooking->client_id)
    . "</custom_account_id__c>";

This is quite handy when trying to link records without have to resort to using their Salesforce ID.

I'm wondering is there a similar type of shorthand I can use when setting up the Record Type on objects via the API. Having to get the record type id by first querying the Record Type object is a step I'd like to cut out if at all possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤云独去闲 2024-11-16 14:46:02

您可以使用 RecordType 上的名称字段来执行此操作,您生成的 xml 应该看起来像

    <create xmlns="urn:partner.soap.sforce.com">
        <sobject>
            <type>case</type>
            <subject>Test</subject>
            <recordType>
                <type>RecordType</type>
                <name>InternetCase</name>
            </recordType>
        </sobject>
    </create>

基于您发布的代码,您会这样做

$sfBooking->fields['RecordType'] = "<type>RecordType</type>"
    . "<name>"
    . utf8_encode($tboxBooking->recordType_name)
    . "</name>";

You can do this using the name field on RecordType, your generated xml should look like

    <create xmlns="urn:partner.soap.sforce.com">
        <sobject>
            <type>case</type>
            <subject>Test</subject>
            <recordType>
                <type>RecordType</type>
                <name>InternetCase</name>
            </recordType>
        </sobject>
    </create>

based on the code you posted, you'd do

$sfBooking->fields['RecordType'] = "<type>RecordType</type>"
    . "<name>"
    . utf8_encode($tboxBooking->recordType_name)
    . "</name>";
苹果你个爱泡泡 2024-11-16 14:46:02

大卫,我不知道设置 RecordType 的类似简写方法。不幸的是,RecordType 没有实现此目的所需的外部 ID。

我的建议是查询所有 RecordTypes 并建立一个本地查找表/DeveloperName 到 Id 的数组。然后,您可以在整个应用程序中使用此查找表/数组,根据 Salesforce 中该 RecordType 的 DeveloperName 设置正确的 RecordType Id。

David, I'm not aware of a similar shorthand method of setting the RecordType. Unfortunately the RecordType does not have an external id which is required in order to achieve this.

My recommendation would be to query all of the RecordTypes and build up a local lookup table/array of DeveloperName to Id. You can then use this lookup table/array throughout your application to set the correct RecordType Id based on the DeveloperName of that RecordType in Salesforce.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文