You need to sign in to do that
Don't have an account?
Can someone tell me what this error explains
System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, U#22e.bff (LastEditBy), cannot be null when revision is greater than 1: [LastEditById]
my test class for trigger is:
@isTest(SeeAllData = true)
Public with sharing class ChatterPostTriggerTest{
// Positive test class for ChatterPostTrigger.trigger
public static testMethod void PosTestForSinglePost(){
// Insert the feeditem
FeedItem feed = new FeedItem();
feed.Body = 'This is test class';
//feed.ParentId = u.Id;
feed.ContentDescription = 'this is test class for feed item';
feed.Title ='test class';
feed.Type = 'PollPost';
feed.Revision =2;
insert feed;
}
}
my test class for trigger is:
@isTest(SeeAllData = true)
Public with sharing class ChatterPostTriggerTest{
// Positive test class for ChatterPostTrigger.trigger
public static testMethod void PosTestForSinglePost(){
// Insert the feeditem
FeedItem feed = new FeedItem();
feed.Body = 'This is test class';
//feed.ParentId = u.Id;
feed.ContentDescription = 'this is test class for feed item';
feed.Title ='test class';
feed.Type = 'PollPost';
feed.Revision =2;
insert feed;
}
}
Please update your test class from below code :
Let me know if you still have any issue.
Thanks,
Abhishek
As per the message, if your revision is greater than 1, you also need to specify a value for the field "LastEditById" and "LastEditDate" (as a revision means a change has been applied and hence it asks for the person who last edited it and the date when it was edited.
Few other observations
- if content not needed you might comment out feed.ContentDescription field.
If you need it, then the feed.Type should be one of these: AdvancedTextPost, ContentPost, QuestionPost.
- ParentId is a required field, you might want to add some value there too.
Roughly, if you try the below code, you should be able to create the feeditem.
Hope this helps. Happy coding!