Skip to main content

16:24:03:051 FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Select the community that this participant belongs to.: []

 

This is my code : 

 Id surveyId = [SELECT Id

                       FROM Survey

                       WHERE Name = 'Partner Satisfaction Survey'].Id;

        

        Id communityId = [SELECT Id FROM Community].Id;

 

        SurveyInvitation surveyInv = new SurveyInvitation();

        for(Contact c : lContacts){

            if(c.IsSurveyInvitationSent__c == false){

                surveyInv.Name = 'PartnerSatisfactionSurveyInvitation';

                surveyInv.ParticipantId = c.Id;

                surveyInv.CommunityId = communityId; 

                surveyInv.OptionsAllowGuestUserResponse = true;

                //surveyInv.OptionsAllowParticipantAccessTheirResponse = true;

                surveyInv.SurveyId = surveyId;

                c.IsSurveyInvitationSent__c = true;

                recordsProcessed +=1;

            }

        }

2 risposte
  1. Michael Brown (Salesforce) Forum Ambassador
    9 nov 2022, 20:59

    Hi Astria, 

     

    When using Salesforce Surveys, an experience cloud site is needed because the participants provide their feedback from the Experience Site.  Even if you do not require authentication, the survey link takes users to a non-authenticated experience cloud site.  The good news is you don't need a license and simply just need to create a non-authenticated experience site, without having to build out any pages on said site. 

     

    Thanks,

    Mikey

0/9000