You need to sign in to do that
Don't have an account?
Remove chatter followers?
I've scoured the net and SF boards, but I could not find a single example of how to remove Chatter followers from an object. I'm pretty sure I did it right by just removing the correct EntityRelationship record, but the test method is failing. Either I wrote the removeAllFollowers method wrong, or I wrote the test wrong. Can you take a look and tell me if you see anything obvious? Thanks!
Goal: When a Project__c is closed, remove all Chatter followers.
Problem: When I run my getFollowers() method two different times on the same Project__c object, I get two different records. Driving me crazy.
Nice find! Thanks for checking that out! I wish the boards had better css for pasting code (unless I didn't see it), so it must have been ugly for you to look at. You're find did solve one of my problems, but I still had another.
As it turns out, we had a trigger (that I was unaware of) that was adding the creator of the project as a chatter follower automatically. I couldn't figure out why there was still a chatter follower even after I deleted it. In my debug statements, I could see the user ID of this follower, which was different than the one I added earlier, and I was thinking "Who the eff is still following this project?! I deleted you! Who is this **bleep**!?" I did an extra query to see who this **bleep** was, and when I went to the debug logs to see who it was.....it was me. :-( The creator of the project. Wasted debugging time aside, pretty comical.
Summary: My code is correct (with rwoollen's fix on the getFollowers method). But, another trigger was doing unforeseen things to mess with my test.
All Answers
It looks like your getFollowers() puts an entry into the map even if there are no followers.
-- Rob
Nice find! Thanks for checking that out! I wish the boards had better css for pasting code (unless I didn't see it), so it must have been ugly for you to look at. You're find did solve one of my problems, but I still had another.
As it turns out, we had a trigger (that I was unaware of) that was adding the creator of the project as a chatter follower automatically. I couldn't figure out why there was still a chatter follower even after I deleted it. In my debug statements, I could see the user ID of this follower, which was different than the one I added earlier, and I was thinking "Who the eff is still following this project?! I deleted you! Who is this **bleep**!?" I did an extra query to see who this **bleep** was, and when I went to the debug logs to see who it was.....it was me. :-( The creator of the project. Wasted debugging time aside, pretty comical.
Summary: My code is correct (with rwoollen's fix on the getFollowers method). But, another trigger was doing unforeseen things to mess with my test.