I have a situation, where I want to add records to streams automatically (ignore the 25 limit for now)

If using Flow, I don't see any way to do that.

Is it possible ?

In apex, I need the solution to be dynamic, as each user will have it's own streams, and cases.

public class StreamUpdate {

public static void getId (List<Id> caseIds){
    List<ConnectApi.StreamSubscriptionInput> subscriptions = new List<ConnectApi.StreamSubscriptionInput>();
    for(Id caseId : caseIds){
    ConnectApi.StreamSubscriptionInput sub1 = new ConnectApi.StreamSubscriptionInput();
    sub1.entityId = caseId;
    subscriptions.add( sub1 );
    ConnectApi.ChatterStreamInput streamInput = new ConnectApi.ChatterStreamInput();
    streamInput.name='Followed Case';
    streamInput.subscriptionsToAdd = subscriptions;
    ConnectApi.ChatterStream stream = ConnectApi.ChatterFeeds.updateStream(Network.getNetworkId(), '0Fq3G000000CcP8SAK', streamInput);
    System.debug( stream );
    System.debug( stream.id );
    System.debug( stream.name );
    System.debug( stream.description );
    System.debug( 'Subscriptions:' );
    for ( ConnectApi.FeedEnabledEntity entity : stream.subscriptions ) {
        System.debug( entity.id );    
        System.debug( entity.name );  
        System.debug( entity.type );  


Am I in the right direction at all?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.