function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
hiteshwar marnihiteshwar marni 

how to insert feedpollchoice data in test class?

I'm trying to create feedpollchoice record in test class but it's throwing exception as fields not writable although i have pernission.pls help on this thanks
Amit Chaudhary 8Amit Chaudhary 8
Can you please post your code so that we can help you
hiteshwar marnihiteshwar marni
@isTest
public class VANChatterPollArchiveControllertest {
 Static TestMethod void VAN_FeedCommentTriggerMethod(){
    
 
              list<id> lstfeeditem = new list<id>();
       FeedItem fi1 = new FeedItem(Body = 'samplebody', ParentId = UserInfo.getUserID(),Type = 'PollPost');
      
       insert fi1;
         FeedPollChoice fpc = new FeedPollChoice();
        fpc.ChoiceBody='who is our cm';
        fpc.FeedItemId=fi1.id;
        fpc.Position=2;
       insert fpc;
      
        lstfeeditem.add(Fi1.id);
        FeedItem fi2 = new FeedItem(Body = 'samplebody', ParentId = UserInfo.getUserID());
       
      insert fi2;
       
    
}
}
Amit Chaudhary 8Amit Chaudhary 8
Please post your main class as well for which you are creating test class
Ruben Carvalho 10Ruben Carvalho 10
Using the Workbench you can check that FeedPollChoice is not "creatable" so you won't be able to insert new records programatically.

FeedPollChoice Attributes
activateable: false
compactLayoutable: false
createable: false
custom: false
customSetting: false
deletable: false
deprecatedAndHidden: false
feedEnabled: false
hasSubtypes: false
idEnabled: true
isSubtype: false
keyPrefix: 09A
label: Feed Poll Choice
labelPlural: Feed Poll Choices
layoutable: false
mergeable: false
mruEnabled: false
name: FeedPollChoice
networkScopeFieldName:
queryable: true
replicateable: false
retrieveable: true
searchable: false
undeletable: false
updateable: false
urlDetail:
urlEdit:
urlNew: