You need to sign in to do that
Don't have an account?
dev401has
Insufficient access rights on cross-reference id for Chatter group feed post
Hi
I have created a chatter group (Collaboration type is public). I am trying to post a feed into that using a trigger
the trigger goes like this:
trigger postfeed on custom_object__c(after insert) { for(custom_object__c c: trigger.new) { try { FeedPost fpost = new FeedPost(); // fpost.Type = 'TextPost'; fpost.ParentId = chattergroup.Id; fpost.Body = 'Feedpost to be posted in chatter group'; insert fpost; } } }
and it works for system admin (owner of that chatter group).
but when i log in using another user having different profile (the profile has access to that custom object and user is member of that Chatter group) then it gives following error:
04:20:11.963|DML_BEGIN|[25]|Op:Insert|Type:FeedPost|Rows:1 04:20:12.625|DML_END|[25] 04:20:12.625|EXCEPTION_THROWN|[25]|System.DmlException: Insert failed. First exception on row 1; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: [] 04:20:12.626|METHOD_ENTRY|[29]|ApexPages.addMessages(APEX_OBJECT) 04:20:12.626|VF_PAGE_MESSAGE|Insufficient Privileges 04:20:12.626|METHOD_EXIT|[29]|ApexPages.addMessages(APEX_OBJECT)
Can anyone help me out on how to get rid of this access error?
Is there anything like we need to give access to chatter group for some profiles???
replying my post itself. Hope it helps other.
You can post into Chatter Groups only if you are member of that group.
All Answers
replying my post itself. Hope it helps other.
You can post into Chatter Groups only if you are member of that group.
A work-around is to check if the current user is a member of the group. If not, put the member into the group. This may not work for everyone, but my client finds it acceptable.
Hi David
Thanks for the reply.
I am also doing the similar way. Inserting the member into group, posting the feed and then deleting the member from the group.
I am doing upsert for group member into Group and then checking whether user was inserted or updated. If user was already the member then it would be updated hence no need to delete it and if not i.e. user is inserted then delete the user from group.
But I was not able to find anything for private group hence I had to use this workaround. If somewhere around you come across any solution for Private groups do post back.
Hi David,
I have a commandbutton, "Join Group" through which the authenticated users in site can join the collaboration group.
It works for System administrators, but when i click that button by loggin in as authenticated site user, i am getting the same error--
"Insufficient access rights on cross-reference id".
Any inputs for this??
CollaborationGroupMember cgm = new CollaborationGroupMember(
MemberId = userInfo.getUserID(),
CollaborationGroupId = chatterGroup.id);
try
{
insert cgm;
}
catch(DMLEXCepion e)
{
//display dml error
}
I am inserting the group member like this