You need to sign in to do that
Don't have an account?
Amit Visapurkar 5
Test class for Chatter CollaborationGroup
trigger ChatterGroupM on CollaborationGroup (after insert) {
for(CollaborationGroup e:Trigger.New){
List<User> users=[select id, Username from User where CompanyName='Bodhtree' AND IsActive=true];
e = [select id, OwnerId,Name from CollaborationGroup where Id=:Trigger.New];
List<CollaborationGroupMember> ChatterM = new List<CollaborationGroupMember>();
//List<CollaborationGroupMember> ChatterM = [SELECT MemberId FROM CollaborationGroupMember WHERE CollaborationGroupId='0F9m00000004K33'];
for(User user:users){
system.debug('The Group Name is ' + e.Name);
if(e.OwnerId==user.Id){}
else{
CollaborationGroupMember CollMember= new CollaborationGroupMember(CollaborationGroupId=e.id,MemberId = user.Id);
system.debug('The memberId is ' + CollMember.MemberId);
ChatterM.add(CollMember);
system.debug('The ownerId is ' + e.OwnerId);
system.debug('The users are ' + ChatterM);
}
}
insert ChatterM;
}
}
How to write the test class for the CollaborationGroup. Its urgent
for(CollaborationGroup e:Trigger.New){
List<User> users=[select id, Username from User where CompanyName='Bodhtree' AND IsActive=true];
e = [select id, OwnerId,Name from CollaborationGroup where Id=:Trigger.New];
List<CollaborationGroupMember> ChatterM = new List<CollaborationGroupMember>();
//List<CollaborationGroupMember> ChatterM = [SELECT MemberId FROM CollaborationGroupMember WHERE CollaborationGroupId='0F9m00000004K33'];
for(User user:users){
system.debug('The Group Name is ' + e.Name);
if(e.OwnerId==user.Id){}
else{
CollaborationGroupMember CollMember= new CollaborationGroupMember(CollaborationGroupId=e.id,MemberId = user.Id);
system.debug('The memberId is ' + CollMember.MemberId);
ChatterM.add(CollMember);
system.debug('The ownerId is ' + e.OwnerId);
system.debug('The users are ' + ChatterM);
}
}
insert ChatterM;
}
}
How to write the test class for the CollaborationGroup. Its urgent
Sincerely regret the inconvenience for the delayed reply.
Already this query has a solution on the stack exchange with same issue.
http://salesforce.stackexchange.com/questions/139655/how-to-create-test-class-for-chatter-collaboration-group
Hope this helps.
Kindly mark this thread as solved if it's resolved.
Best Regards,
Nagendra.P
Did you get any ideas on this. Please response i am also stuck in same situation.
I am able to insert CollaborationGroup but whenever I am trying to insert CollaborationGroupMember in it, it is showing insufficient_Error from admin user.
Thanks,
Gaurav
Use this code
CollaborationGroup groupe = new CollaborationGroup(Name = 'Test1', CollaborationType = 'Public');
insert groupe;
Profile prof = [select id from profile where name LIKE '%System%'];
User u = new User(Alias = 'sd', Email='ser@testorg.com',
EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = prof.Id,
TimeZoneSidKey='America/Los_Angeles', UserName='ser@testorg.com');
insert u;
collaborationgroupmember cgm = new collaborationgroupmember();
cgm.CollaborationGroupId = groupe.Id;
cgm.MemberId = u.Id;
cgm.CollaborationRole = 'Standard';
cgm.NotificationFrequency='P';
insert cgm;