0

読み取り専用のグループ + いいね + コメントを作成し、管理者と所有者以外のメンバーが投稿できないようにする方法を知りたい * このグループの投稿でトリガーを使用する方法?.

私は試しましたが、うまくいきません:

trigger N_GroupReadOnly on FeedItem (before insert) {

ID groupId = [Select Id from CollaborationGroup where Name = 'Group_ReadOnly'].Id;
CollaborationGroup ownerId = [Select OwnerId From CollaborationGroup Where Name = 'Group_ReadOnly'];
for(FeedItem item : trigger.new){
    if((item.ParentId == groupId) && (item.InsertedById != ownerId.OwnerId)){
        system.debug('you can not add post in this group');
        alert("you can not add post in this group");
        delete item ;
        return;
    }
    else{
        insert item;
    }
}

}

ありがとうございました。

4

1 に答える 1