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
Ragula SivakumarRagula Sivakumar 

We are using survey monkey to capture Prospect based on survey . Once they completed the survey the Prospects along with survey responses will capture in sales cloud.

We are using survey monkey to capture Prospect  based on survey . Once they completed the survey the Prospects along with survey responses will capture in sales cloud.
we will like to import only  if the question answer is yes then corresponding prospects will  transferred to CRM.
Somehow i have tried with this code and i tired also using bulk upload and its is working without any error.

Can someone let me know if i need to modify anything ?.




trigger deletesurvey1 on Survey_response__c (After insert) {
if(Trigger.isAfter){ 
//if (Trigger.isDelete){ 
Survey_response__c[] AllChildRecords = [Select id, Lead__c From Survey_response__c Where Survey_Question__c=:Label.Question and  Response__c=:Label.Response];
       List<id>leadlist= New List<id>();
       
       if(AllChildRecords.size()>0){
       for(Survey_response__c rec : AllChildRecords){
        leadlist.add(rec.Lead__c);
          }  
          } 
          
          List<Survey_response__c>surveyres= New List<Survey_response__c>();
         for(Survey_response__c rec1 : [select id  from Survey_response__c where Lead__c IN:leadlist]){
           surveyres.add(rec1);
           
}
          
        delete surveyres;
        delete   [select id from Lead where id IN :leadlist]
Ragula SivakumarRagula Sivakumar
I am deleting the data based on question and  response .
if question is "abcd" and  response is "no"   deleting the  lead and corresponding survey's