Last active
June 2, 2020 00:28
-
-
Save RockyMtnMarc/303cb1f17c6cc9e019cf9458f6b13571 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This trigger updates the LiveChatTranscript.Survey_URL__c field with a valid SurveyInvitation URL and creates a lookup relationship from the SurveyInvitation.Chat_Transcript__c to the LiveChatTranscript | |
trigger LiveChatTranscript_CreateSurveyURL on LiveChatTranscript (before update) { | |
for (LiveChatTranscript lct : Trigger.New){ | |
if(lct.Status == 'Waiting'){ | |
List<SurveyInvitation> thisSurveyInvitation = [SELECT Id, UUID, Name FROM SurveyInvitation WHERE ChatKey__c = :lct.ChatKey LIMIT 1]; | |
//Set the surveyName variable to the API name of your Survey record | |
lct.Survey_URL__c = 'https://sdodemo-main-166ce2cf6b6-16bd728c779.force.com/consumer/survey/runtimeApp.app?invitationId=' + thisSurveyInvitation[0].Id + '&surveyName=hutch_test&UUID=' + thisSurveyInvitation[0].UUID; | |
if (thisSurveyInvitation.size() > 0){ | |
try { | |
thisSurveyInvitation[0].Chat_Transcript__c = lct.Id; | |
update thisSurveyInvitation[0]; | |
} catch (DmlException e) { | |
system.debug('Case update error: ' + e); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment