This is possible to create a trigger on Survey object, but DML operation insert is forbidden on Survey object. How one can cover Survey Trigger with a test?

  • I have seen a couple of questions around survey objects which are not writable. At this point it seems to be not allowed and unfortunately there wont be a way to cover and test the trigger. You may look at this question or the issue. These links are for Survey response which has same behaviour.
    – manjit5190
    Mar 26 '20 at 16:48

To test the trigger

trigger SurveyTrigger on Survey(before insert){
    //factor your logic to a  handler class and method

we could try to catch to exception of DML operation insert is now allowed

private static void survey(){
    Survey s = new Survey();
        insert s;
    catch(Exception e){
  • Same applies to SurveyInvitation?
    – Ysr Shk
    Nov 8 '21 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.