I'm working with an answer submitted here to be able to post to a group and automatically link to an Opportunity. I'm going to use the VF page as a custom Publisher action.
This post was very helpful, but I'm trying to figure out a couple things. 1) is there a way I could hard code the group that the post is pointed to (versus asking user to input the ID). Its always going to be same for this use case. 2) Is there a way to have the opportunity be dynamically be pulled in based on the opportunity record the post is generated from (versus typing in ID). I'm thinking no since the controller used is Chatter? 3) If it is able for the Opp to be pulled in - can I also pull in standard fields to the opportunity (Like Account Name/Amount).
(I'm a Visualforce newbie so be kind).
VISUALFORCE CODE:
<apex:page controller="ChatterPostController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Post" action="{!doPost}" />
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:outputLabel value="Path to Win"/>
<apex:inputText value="{!detail}" style="width: 255px !important;" />
<apex:outputLabel value="Opportunity ID"/>
<apex:inputText value="{!OppId}" />
<apex:outputLabel value="Group ID"/>
<apex:inputText value="{!groupId}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
CONTROLLER:
public with sharing class ChatterPostController {
public String detail {get; set;}
public Id oppId {get; set;}
public Id groupId {get; set;}
public PageReference doPost()
{
FeedItem fitem=new FeedItem();
fItem.parentId=groupId;
fItem.body=detail + ' Opportunity: ' + System.URL.getSalesforceBaseUrl().toExternalForm() + '/' + oppId;
insert fItem;
return null;
}
}