Created
January 15, 2014 00:24
-
-
Save britishboyindc/8428614 to your computer and use it in GitHub Desktop.
Adding Feed Item into a Chatter Feed of Opportunity (source) object for a new Grant Record (Target)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Opportunity opty = new Opportunity(Id = '006i000000A0T3t'); | |
| Grant_Management__c grd = new Grant_Management__c(Name = 'Test 123'); | |
| insert grd; | |
| ConnectApi.FeedItemInput input = new ConnectApi.FeedItemInput(); | |
| ConnectApi.MessageBodyInput messageInput = new ConnectApi.MessageBodyInput(); | |
| ConnectApi.TextSegmentInput textSegment; | |
| ConnectApi.LinkSegmentInput linkSegment; | |
| messageInput.messageSegments = new List<ConnectApi.MessageSegmentInput>(); | |
| textSegment = new ConnectApi.TextSegmentInput(); | |
| textSegment.text = ' New Grant Record Created: '; | |
| textSegment.text += ' \n '; | |
| messageInput.messageSegments.add(textSegment); | |
| linkSegment = new ConnectApi.LinkSegmentInput(); | |
| linkSegment.URL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + grd.Id; | |
| messageInput.messageSegments.add(linkSegment); | |
| input.body = messageInput; | |
| ConnectApi.FeedItem feedItemRep = ConnectApi.ChatterFeeds.postFeedItem(null, ConnectApi.FeedType.Record, opty.Id, input, null); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment