You need to sign in to do that
Don't have an account?
Christina Wallace
Chatter Post on behalf of Someone.
I' m banging my head. I have got a button to allow Leaders to blast a Chatter post when we have updates. However to make it easier on our users to get it, we are having them follow a User that just blast these update.
The Leaders are admins (as am I) and have it checked to allow "Insert System Field Values for Chatter Feeds" in our profile and in the code I have
FeedItem post = new FeedItem();
String s = 'THe Message';
post.ParentId = landingChatterGroup.Id;
System.debug('Concierge.Id ' + Concierge.Id);
post.createdById = Concierge.Id;
post.Body =s;
post.Type = 'TextPost';
insert post;
I am getting INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: [
What am I missing? The user is a Manager in the chatter group I am trying to add the post to.
The Leaders are admins (as am I) and have it checked to allow "Insert System Field Values for Chatter Feeds" in our profile and in the code I have
FeedItem post = new FeedItem();
String s = 'THe Message';
post.ParentId = landingChatterGroup.Id;
System.debug('Concierge.Id ' + Concierge.Id);
post.createdById = Concierge.Id;
post.Body =s;
post.Type = 'TextPost';
insert post;
I am getting INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: [
What am I missing? The user is a Manager in the chatter group I am trying to add the post to.
This is not a limitation exactly. You have to pass "Current Community Id" in "NetworkScope" field of FeedItem. You can refer to the below link for details
https://help.salesforce.com/apex/HTViewSolution?id=000187667&language=en_US
Let me know if this works.
All Answers
Just to confirm, landingChatterGroup is the Chatter Group that you are trying to put the FeedItem into correct?
What is Concierge? Is that a User/Public Group? Do you have access to that?
Try commenting out the post.createdById and doing the insert first. If insert succeeds then its probably that you do not have access to the Concierge group.
User Concierge = new User();
//get LandingChatter
if (cgs.size() > 0) {
landingChatterGroup = cgs.get(0);
} else {
landingChatterGroup = new CollaborationGroup();
}
//get User
List <User> ConciergeSearch = [select id, name from user where firstname = 'Veranda' and LastName='Concierge'];
if (ConciergeSearch.size() > 0) {
Concierge = ConciergeSearch.get(0);
} else {
Concierge = new User();
}
FeedItem post = new FeedItem();
String s = 'THe Message';
post.ParentId = landingChatterGroup.Id;
System.debug('Concierge.Id ' + Concierge.Id);
post.createdById = Concierge.Id;
post.Body =s;
post.Type = 'TextPost';
insert post;
If the above two dont hold, try adding this line
post.Visibility = 'AllUsers'
let me know if it works
but I think the issue is my group is a Community Chatter group. I was able to get it to post to my Internal Salesforce Chatter via myself and to have this user (Concer.) post to me on my Salesforce Chatter. How come I have a feeling this is going to be a limitation issue with Community Chatter?
This is not a limitation exactly. You have to pass "Current Community Id" in "NetworkScope" field of FeedItem. You can refer to the below link for details
https://help.salesforce.com/apex/HTViewSolution?id=000187667&language=en_US
Let me know if this works.