You need to sign in to do that
Don't have an account?
Record is not getting inserted in new Object in FeedItem trigger
I have a sobject TestStoring__c with one custom field Body__c.In after insert trigger on FeedItem , when i insert a record in
TestStoring__c sobject,it is not getting inserted.I am also attaching the code below.
Trigger:
trigger Test on FeedItem (after insert)
{
FeedItem[] f=Trigger.New;
TestTriggerClass.addFeedError(f);
System.debug(TestTriggerClass.flag);
if(TestTriggerClass.flag!='done')
{
TestStoring__c vv=new TestStoring__c();
vv.Body__c=f[0].body;
insert vv;
}
}
Class:
public class TestTriggerClass
{
public static string flag;
public static void addFeedError(list<FeedItem> fi)
{
if(fi[0].body.contains('blocked'))
{
flag='not';
fi[0].adderror('Not Allowed');
return;
}
else
{
flag='done';
return;
}
}
}
If you have any solution please help me?Its urgent.please
Thanks
Anil Meghnathi
Hi
Try this code :
trigger Test on FeedItem (after insert)
{
for(FeedItem fd : trigger.new){
if(fd.flag!='done'){
TestStoring__c vv=new TestStoring__c();
vv.Body__c=f[0].body;
insert vv;
}
}
don't forget to bulkify it
Sorry crop 1645
Following error is comming.
Invalid field flag for SObject FeeItem
Any other idea?
Anil