0

Im trying to send surveys Apex, as indicated in the documentation, we must pass a String and a ConnectApi.SurveyInvitationEmailInput, but passing these parameters gives me the following error:

Method does not exist or incorrect signature: void sendSurveyInvitationEmail(String, ConnectApi.SurveyInvitationEmailInput) from the type Survey.

I've also tried not to pick up what it returns but it doesn't work this way either. The survey settings are activated in my org. What am I missing?

Documentation: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_Survey_static_methods.htm#apex_ConnectAPI_Surveys_sendSurveyInvitationEmail_1

Code:

        String surveyId = [SELECT Id FROM Survey WHERE DeveloperName = 'survey_test' LIMIT 1][0].Id;
        ConnectApi.SurveyInvitationEmailOutput surveyOutput = new ConnectApi.SurveyInvitationEmailOutput();
        ConnectApi.SurveyInvitationEmailInput surveyInput = new ConnectApi.SurveyInvitationEmailInput();
        surveyOutput = Survey.sendSurveyInvitationEmail(surveyId, surveyInput);
3
  • 1
    hi Mariia! I tried to fill some of them but I still get the same error, even some of the required ones like isPersonal​Invitation, I get this error when I try to inform it: 'Variable does not exist: isPersonal​Invitation'
    – Gatosaurio
    Commented Nov 21, 2022 at 16:39
  • May you please also check the API version of your class? Should be 50 or higher. (never mind, it doesn't work in developer console either) Commented Nov 21, 2022 at 16:42
  • Yes, thats what I thought at first, but its the API version 55 :( thx a lot for your help anyways! :)
    – Gatosaurio
    Commented Nov 21, 2022 at 16:49

1 Answer 1

1

The ApexType is Surveys, not Survey in the ConnectApi namespace. Survey is in namespace Schema and represents the SObject.

surveyOutput = ConnectApi.Surveys.sendSurveyInvitationEmail(surveyId, surveyInput);
6
  • I also tried that and its not working for me, I get this error: 'Variable does not exist: Surveys' but if I write 'Survey' it seems ok, am I missing to add something additionally? thx a lot for your help :) looks like there is also an ApexType for Survey, im very confused right now: developer.salesforce.com/docs/atlas.en-us.228.0.apexcode.meta/…
    – Gatosaurio
    Commented Nov 21, 2022 at 16:53
  • updated my answer to include namespace
    – cropredy
    Commented Nov 21, 2022 at 16:58
  • Wow, amazing! For real, the docs are misleading. Commented Nov 21, 2022 at 17:00
  • @Gatosaurio I understood the difference, your documentation is set to v50, if you change it to v56, it will automatically change Survey on Surveys Commented Nov 21, 2022 at 17:03
  • I filed a doc feedback form -- as you can see, this caused me some grief as well to get to work
    – cropredy
    Commented Nov 21, 2022 at 17:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .