Created
March 28, 2013 13:38
-
-
Save richardvanhook/5263178 to your computer and use it in GitHub Desktop.
Set Notification Frequency for all members of a Chatter Group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final String NEW_FREQ_FOR_ALL_GROUP_MEMBERS = 'P'; //P=>On each post, D=>Daily, W=>Weekly, N=>Never | |
final String GROUP_ID = 'CHANGE_ME'; //select id,name from CollaborationGroup | |
final List<CollaborationGroupMember> members = [ | |
select id, NotificationFrequency | |
from CollaborationGroupMember | |
where CollaborationGroupID = :GROUP_ID | |
and NotificationFrequency != :NEW_FREQ_FOR_ALL_GROUP_MEMBERS | |
]; | |
if(members != null && members.size() > 0){ | |
for (CollaborationGroupMember member : members) { | |
member.NotificationFrequency = NEW_FREQ_FOR_ALL_GROUP_MEMBERS; | |
} | |
update members; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Please guide me to write the similar code in Batch class.
Requirement is "Need to override the Notification Frequency of all members of the given Chatter Group "
Details:
Digest_Group__c is a custom object with 2 fields "Name" and "Notification_Frequency__c"
Group ID ='0F9K00000004M86KAE'
Here is my code:
global class batchFrequencyUpdate implements Database.Batchable {
global Database.QueryLocator start(Database.BatchableContext BC) {
String g= '0F9K00000004M86KAE';
String members='select id,MemberId,NotificationFrequency from CollaborationGroupMember where CollaborationGroupID = :g';
return Database.getQueryLocator(members);
}
}
Actual Result: Notification frequecy is not updating.
Thanks in advance.