1

I'm trying to set a trigger to link the results of a survey to the relevant case or chat transcript. It seems SurveyForce was not meant to do that but I tried adding a question on the survey that stores the Chatkey. And here is the code of the trigger :

trigger Test on LiveChatTranscript (before insert) 
{
    set<string> allSurveyStrings = new set<string>();

    for (SurveyTaker__c b : trigger.new)
       {
       allSurveyStrings.add(b.Response);
       }


    for (LiveChatTranscript a: Trigger.new)
       {

       Id SurveyTaker__c= [SELECT id FROM SurveyTaker__c WHERE Response.contains(a.chatKey) IN : allSurveyStrings]

       a.SurveyTaker__c = Id SurveyTaker__c;
       }

}

However the building fails everytime saying "Didn't understand relationship 'a' in field path"

Any help please ?

4
  • Where did you get the Response.contains(a.chatKey) part ? That doesn't look like valid SOQL. Commented Aug 7, 2015 at 12:25
  • One of the Responses of the SurveyTaker__c object I want to select contains the ChatKey field from the LiveChat Transcript a. How should I write it then ? Commented Aug 7, 2015 at 15:48
  • I think you are looking for the LIKE operator, which you may need to use in dynamic soql rather than building your query like this + pay attention to bulkification. It may be better to first start with some tutorials or trailheads on apex and soql before writing production code. Commented Aug 7, 2015 at 16:17
  • You're right, I should start with something easier, but don't worry I only did that on a sandbox ! Thank you for your help Commented Aug 7, 2015 at 16:24

0

You must log in to answer this question.

Browse other questions tagged .