Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Chatter Development
- :
- Chatter trigger to create new Idea record
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Chatter trigger to create new Idea record
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-09-2012 10:05 AM
Disclaimer: I'm a newbie at programming in Apex.
My company wants to use a Chatter group to allow employees and customers to submit and comment on new product ideas. I need to write a trigger so that when a new FeedItem is created on the New Ideas group in Chatter, it creates a new Idea record, linked to the FeedItem.
Does anyone have an example of creating a new Idea object each time a new Chatter post occurs?
This is what I have so far, and of course, I get an error just saying that Salesforce has been notified.
trigger createNewIdeaTrigger on FeedItem (before insert) {
for (FeedItem f: trigger.new)
{
Idea newIdea = new Idea(Categories = 'NewIdea', Status = 'New', Body = f.Body, CommunityId = '09a300000004gvG', Title = 'New Idea') ;
f.parentId = newIdea.Id;
newIdea.postID__c = f.Id;
insert newIdea;
}
}
Solved! Go to Solution.
Re: Chatter trigger to create new Idea record
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-09-2012 02:03 PM
Apparently, the only issues I had were the following:
a) for some reason, it wouldn't let me run this trigger in the "before Insert" -- only "after insert".
b) The parent.id wasn't write-able.
It now works.

