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
Giancarlo AmatiGiancarlo Amati 

How to unpublish a feed comment/item

Hi All,

We are building an Experience Community. We'd like to implement the feature that when a user marks a feed comment/item with "Flag" see snapshot. The item will be unpublished. 

I tried to search for example of FeedComment and / or FeedItems, I think this can be done with a FeedItem trigger, but can't figure out hlw.

User-added imageThank you for your help.

GC

SwethaSwetha (Salesforce Developers) 
HI Giancarlo,
You can take reference of code snippet from https://help.salesforce.com/s/articleView?id=sf.networks_moderation_flag_triggers.htm&type=5 for fetching flagged posts on FeedItem and FeedComment to get started. 

Meanwhile, I am also trying this in my org.Thanks
 
Giancarlo AmatiGiancarlo Amati

Thank you, Swetha. Yes, I found that article and I started from there. My understanding however is that the FeedItem doesn't trigger an "update" event when it gets flagged. I understand that the NetworkScope object gets updated. But it's not possible to build a trigger on the NetworkScope object. I wanted to build the query to retrieve the NetworkSope Id record to access the Visibility field with the Developer Console. We did it, but we tried to update the value of the "visibility" field and it generated a DLM error message.

If we have to build a scheduled Apex job that's fine however, If we can make the post hide as soon as it gets flagged, would be ideal.

Thank you,

GC