I'm trying to develop some code to post the link for an opportunitylineitem and an account as a dynamic link on the feedpost details.
My current code snippet is:
This works but it posts two feedposts:Code:if(opportunityFeedPosts.size() == 0 || opportunityFeedPosts[0].FeedPost.Body != bodyText) { //System.debug('OpportunityFeed Posts: '+opportunityFeedPosts[0]); FeedPost opportunityPost = new FeedPost (); opportunityPost.Type = 'LinkPost'; opportunityPost.Title = ''+entries.get(newOLI.Pricebookentryid).Product2.ProductCode+' socket details'; //opportunityPost.Title = 'Account: '+opp.get(newOLI.OpportunityId).Account.Id+'.'; opportunityPost.Body = bodyText; //String id = String.valueOf(opp.get(newOLI.OpportunityId).Account.Id).substring(0,15); String id = String.valueOf(newOLI.Id).substring(0,15); opportunityPost.LinkURL = 'https://cs2.salesforce.com/'+id; opportunityPost.ParentID = newOLI.opportunityid; posts.add(opportunityPost); System.Debug('Got Here but did not post'); FeedPost opportunityPost2 = new FeedPost (); opportunityPost2.Type = 'LinkPost'; opportunityPost2.Title = 'Account Details'; opportunityPost2.Body = bodyText; String id2 = String.valueOf(opp.get(newOLI.OpportunityId).Account.Id).substring(0,15); opportunityPost2.LinkURL = 'https://cs2.salesforce.com/'+id2; system.debug('got here and it should have posted twice'); opportunityPost2.ParentID = newOLI.opportunityid; posts.add(opportunityPost2);
Anyone have ideas on putting that into one feedpost?
Bookmarks