【问题标题】:Creating a Multi-Contact Event with Apex in Salesforce在 Salesforce 中使用 Apex 创建多联系人事件
【发布时间】:2019-08-09 16:13:59
【问题描述】:

我正在尝试使用 Apex 创建多联系人事件。

我已经在临时组织的活动设置中启用了Allow Users to Relate Multiple Contacts to Tasks and Events

我正在关注these 文档底部的指南和示例,但在推送到临时组织时我经常遇到错误:

// ...
event.setEventWhoIds(attendeeContactIds);
// ...

Method does not exist or incorrect signature: void setEventWhoIds(List<String>) from the type Event.

我也尝试直接写到该字段:

event.EventWhoIds = attendeeContactIds;

这样,我得到错误,该字段不可写。

attendeeContactIds 是代表联系人 ID 的字符串列表。

我会错过什么? ????????????‍♂️

【问题讨论】:

    标签: salesforce apex


    【解决方案1】:

    这有点愚蠢,它在 apex 中是只读的。它是公开的,因此集成可以在一个全有或全无的事务中快速创建事件和本质上的相关列表。另见https://salesforce.stackexchange.com/questions/238094/eventwhoids-is-not-writeable-in-apex-class-but-working-on-jsforce

    试试这样的?

    Savepoint sp = Database.setSavepoint();
    
    event e = new Event(
        StartDateTime = System.now(),
        EndDateTime = System.now().addHours(1)
    );
    insert e;
    
    List<EventRelation> invitations = new List<EventRelation>();
    for(Contact c : [SELECT Id FROM Contact LIMIT 5]){
        invitations.add(new EventRelation(
            EventId = e.Id,
            RelationId = c.Id,
            IsInvitee = true
        ));
    }
    insert invitations;
    
    Database.rollback(sp); // unless you really want to send it out
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-25
      • 1970-01-01
      • 2014-08-14
      • 2022-10-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多