【问题标题】:How to modify the LoadConvert Apex payload?如何修改 LoadConvert Apex 有效负载?
【发布时间】:2022-11-03 05:29:42
【问题描述】:

我在 LeadConvert 更新事件下编写了一个触发器,如下所示:

trigger WebhookSenderTriggerLeadConvert on Lead (after update) {
    if (Trigger.new.size() == 1) {
        if (Trigger.old[0].isConverted == false && Trigger.new[0].isConverted == true) {
            if (Trigger.new[0].ConvertedAccountId != null) {
                String url = 'https://mydomain.io';
                String content = WebhookSender.jsonContent(Trigger.new, Trigger.old);
                WebhookSender.callout(url, content);
            }
        }
    }
}

这在开发 Salesforce 上对我有用,并且在我正确接收的有效负载中:

{
    "new":[
        {
            "attributes":{
                "type":"Lead",
                "url":"/services/data/v56.0/sobjects/Lead/B00000000000000000"
            },
            "Id":"B00000000000000000",
            ...(+30 more fields)
        }
    ],
    "old":[
        {
            "attributes":{
                "type":"Lead",
                "url":"/services/data/v56.0/sobjects/Lead/B00000000000000000"
            },
            "Id":"B00000000000000000",
            ...(+30 more fields)
        }
    ],
    "userId":"A00000000000000000"
}

但是,在另一个第三方 Salesforce 帐户中,我得到以下信息:

{
    "new":[
        {
            "attributes":{
                "type":"Lead",
                "url":"/services/data/v56.0/sobjects/Lead/C00000000000000000"
            },
            ...(9 more fields)
        }
    ],
    "old":[
        {
            "attributes":{
            },
            ...(9 more fields)
        }
    ],
    "userId":"D00000000000000000"
}

我在这里混淆了很多字段,因为其中很多都是敏感的,但我无法确定是什么导致第三方 Salesforce 中的大部分字段不存在,包括 Id 字段,在开发 Salesforce 中,一切都存在。

有什么可能会这样做吗?

【问题讨论】:

    标签: api salesforce apex apex-code salesforce-development


    【解决方案1】:

    那么,两者的 WebhookSender 类是否相同?它会将收到的所有字段转储为 JSON,还是包含一些与安全相关的代码,例如“stripInaccessible”?

    是不是您的开发组织在潜在客户表中的自定义字段比其他组织多 20 多个?

    您缺少的字段是否来自受管软件包?他们会有namespace__FieldName__c 格式。如果您知道这些字段存在,但您的用户没有该受管软件包的许可证 - 它们可能会被隐藏。

    【讨论】:

      猜你喜欢
      • 2012-09-18
      • 1970-01-01
      • 1970-01-01
      • 2021-11-15
      • 2012-06-21
      • 2020-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多