You need to sign in to do that
Don't have an account?
sfdc007
Chatter Post requirement help needed
Hi,
I have a following requirement for which i need help on it related to chatter post
1) I have enabled the chatter post for opportunity object
My requirment is
whenever i enter some chatter post in opportunity and post it it should capture account id and opportunity id automatically and those ids should be visible in the chatter post to whom i post to.
can it be done through configuration in salesforce ?
Let me know how to achieve this requirement
Thanks in Advance
I have a following requirement for which i need help on it related to chatter post
1) I have enabled the chatter post for opportunity object
My requirment is
whenever i enter some chatter post in opportunity and post it it should capture account id and opportunity id automatically and those ids should be visible in the chatter post to whom i post to.
can it be done through configuration in salesforce ?
Let me know how to achieve this requirement
Thanks in Advance
trigger FeedItemTrigger on FeedItem (before insert) {
set<id> parentAccountIds = new set<id>();
for(FeedItem fdItem : trigger.new){
String idStr = fdItem.Parentid;
if(idStr.startsWith('001')){
parentAccountIds.add(idStr);
}
}
Map<id,Account> accounts = new Map<id,Account>([Select id, name from Account where id in:parentAccountIds]);
for(FeedItem fdItem : trigger.new){
Account parentAccount = accounts.get(fdItem.Parentid);
String chatterBody = fdItem.Body;
fdItem.Body = chatterBody + '\n Account Id is :'+parentAccount.id + ':: Account Name ::'+parentAccount.Name;
}
}
All Answers
Feed Item Have Parent id field from where you can determine the Opportunity and Information.
Just update the Body with info you like on Before insert trigger
FeedItem post = new FeedItem(); post.ParentId = oId; //eg. Opportunity id, custom object id.. post.Body = 'Enter post text here'; insert post;
trigger FeedItemTrigger on FeedItem (before insert) {
set<id> parentAccountIds = new set<id>();
for(FeedItem fdItem : trigger.new){
String idStr = fdItem.Parentid;
if(idStr.startsWith('001')){
parentAccountIds.add(idStr);
}
}
Map<id,Account> accounts = new Map<id,Account>([Select id, name from Account where id in:parentAccountIds]);
for(FeedItem fdItem : trigger.new){
Account parentAccount = accounts.get(fdItem.Parentid);
String chatterBody = fdItem.Body;
fdItem.Body = chatterBody + '\n Account Id is :'+parentAccount.id + ':: Account Name ::'+parentAccount.Name;
}
}