Velocity script for service satisfaction survey

Frederique_Lans
Level 1

Velocity script for service satisfaction survey

We want to send a service satisfaction survey to customers whose service request has closed in the past week.

The service request information is stored in SFDC. The survey is created in GetFeedback.

We are using a velocity script within a token to build the unique survey URL. The URL is built as follows:

#set($url1 = "")

#set($url2 = "")

#set($url3 = "")

#set($url4 = "")

#set($url5 = "")

      #set($url1 = "https://datacolor.getfeedback.com/preview/Yt8sKdGu?ContactID=")

      #set($url2 = "&CaseID=")

      #set($url3 = "&Survey_Name=Service&Service_Request=")

      #set($url4 = "&Service_Request_Owner=")

      #set($url5 = $url1 + ${lead.Unique_Contact_Id__c} + $url2 + ${CaseList.get(0).Id} + $url3 + ${CaseList.get(0).CaseNumber} + $url4 + ${CaseList.get(0).OwnerId})  

      <a href="${url5}" class="mktNoTrack" style="text-decoration: none; color: #cb333b;">Start Survey ›</a>

A smart list in a campaign is used to select the customers who have a service request with the status “closed” and the closed date has a time frame of “this week”.

Some customers might have several outstanding service requests. Therefore it is necessary to select the most recently closed service request.

For this reason we have tested adding $sorter.sort, #foreach and #if commands, but this does not work yet.

It also seems like the smart list conditions and the email script token do not match together.

A customer who had several outstanding service requests, received the survey URL based on the most recent service request which was not closed.

Does anyone have suggestions on how to fix the velocity code?

Thank you in advance.

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity script for service satisfaction survey

First, when posting code, always use the Advanced Editor's syntax highlighter so it's readable:

https://s3.amazonaws.com/blog-images-teknkl-com/syntax_highlighter.gif

Next:

  • Your variable naming conventions are confusing.  $url1 through $url5 are URL components, not URLs.  You also don't need to initialize these vars as empty unless you have a specific reason, like you're reusing them for multiple URLs in the same email.
  • You shouldn't use ${formal} notation in #set directives because it breaks chaining. Use $simple notation.

Then:

  • List.get(0) is always getting the first index, same as List[0]. You need to filter the list for the Status and Closed Date ($sorter.sort-ing alone will not help). I've written many examples in the past. Have you read my posts here and at https://blog.teknkl.com/tag/velocity?