You need to sign in to do that
Don't have an account?

How to AutoFollow a group of People
I am trying to write a trigger that will autofollow a group users to every new record in the object MPS__c
I have been able to automatically follow one user to the record, but when I try to autofollow additional users, I recieve the following error:
Error: Compile Error: Duplicate field initialization: subscriberid at line 24 column 34
Here is my trigger:
trigger MPSFollowers on MPS__c (After Insert) { Set<Id> mIds = new Set<Id>(); Set<Id> fId = new Set<Id>(); for(MPS__c mps :trigger.new) { mids.add(mps.id); System.debug('**** 1 mps id : '+ mps.id); } List<MPS__c> p = [select id from MPS__c where id in :mIds]; List<User> u1 = [select id from User where name = 'Shawn Prendiville']; List<User> u2 = [select id from User where name = 'Mariann Harmon']; List<User> u3 = [select id from User where name = 'Paul van Vugt']; List<User> u4 = [select id from User where name = 'Gary Brown']; List<User> u5 = [select id from User where name = 'Dave Setzer']; EntitySubscription follow = new EntitySubscription ( parentId = p[0].id, subscriberid = u1[0].id, subscriberid = u2[0].id ); insert follow; }
How do I bulkify this trigger and assign multiple users to follow the record?
Thank you,
ckellie
I believe you will have to loop through the users which you intend to follow the your entity to create multiple entity subscription records.
All Answers
I believe you will have to loop through the users which you intend to follow the your entity to create multiple entity subscription records.
Thank you very much.
Hi ckellie
I am facing the same problem,could you please provide me sample code for this.
Thanks
Was this solved, would love to see how you solved it. Thanks
This was solved: