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
carol shi 11carol shi 11 

如何在创建一个case后新增一个FeedComment

在页面New Case,在 Case Feed页面显示一条评论
Ajay K DubediAjay K Dubedi
嗨,卡罗尔,


您可以通过在case对象上触发来满足您的要求。
我在这里举一个例子来了解编码思想-

 
trigger createFeedComment on case(after insert)
{
FeedComment fc = new FeedComment();
fc.CommentBody = 'It is the test comment after creating the case.';
fc.Status = 'Published';
fc.CommentType = 'ContentComment';
insert fc;

}

上面的触发器是在自动创建案例后创建提要注释。
如需更多帮助,请随时询问。


希望以上解决方案对您有所帮助。如果是这样,也请标记为“最佳答案”以帮助他人。

谢谢并恭祝安康,
阿杰·杜贝迪(Ajay Dubedi)
www.ajaydubedi.com
carol shi 11carol shi 11
感谢您的回复,但是新增FeedComment时必须要插入FeedItemId这个栏位,否则执行会报错insert failed
User-added image
Ajay K DubediAjay K Dubedi
嗨,卡罗尔,


尝试这些代码行,这将对您有所帮助。
 
trigger createFeedComment on case(after insert)
{   
    case cs = [select id, accountId,contactId from case where accountId!=null OR contactId!=null limit 1];
    
     FeedItem fi = new FeedItem();
    
    if(cs.accountId != null)
    {
    fi.Body = 'It is the test feedItem comment after creating the case.';
    fi.Status = 'Published';
    fi.ParentId= cs.accountId;
     insert fi;
        
    }
    else if(cs.ContactId != null)
    {
        fi.Body = 'It is the test feedItem comment after creating the case.';
    fi.Status = 'Published';
    fi.ParentId= cs.contactId;
     insert fi;
    }
    
      FeedComment fc = new FeedComment();
      fc.CommentBody = 'It is the test comment after creating the case.';
      fc.Status = 'Published';
      fc.CommentType = 'ContentComment';
      fc.FeedItemId = fi.id;
      insert fc;

}

希望以上解决方案对您有所帮助。如果是这样,也请标记为“最佳答案”以帮助他人。

谢谢并恭祝安康,
阿杰·杜贝迪(Ajay Dubedi)
www.ajaydubedi.com
carol shi 11carol shi 11
select id, accountId,contactId from case where accountId!=null OR contactId!=null limit 1
这段sql是什么意思能,我要的是我当前创建的case下面新增评论。非常感谢您的回复,但这都不是我想要的结果,谢谢