1
0
-1

Hi, I am attempting to use form data after submission in a service that send an email when an option is selected with in the form. 

I have written a HTML parameter which works fine but within that parameter I am attempting to reference form data to customize the email.

I have tried every combination I can find but none will work.

${submission.dataExtractMap.GivenName

${formDataMap.GivenName}

I have used the data extract for all the fields required

 

Any tips??

 

Thanks

  1. Miroslav Botka

    Hi Matt, what service type are you using for this? Are the $submission or $formDataMap objects set at all in your script? You can see the data extracts in the submission details in TM to make sure the data is extracted properly from the form.

  2. Matt Chant

    Hi Miroslav, I am using it for the Submission complete processor. I have written the groovy script to send an email upon submission which works fine. Using the emailService.sendMessage i have a working email that comes through upon submission but for the body of the email I have created a HTML parameter so I can make the body of the email look a bit better and add some data from the form. Its in that HTML parameter that I cant get the form dataextract fields to display. I have checked the form submission data and all extracted data is coming through ok.

CommentAdd your comment...

1 answer

  1.  
    1
    0
    -1

    thanks for the details of the problem in the comments Matt,

    Now I can see you are using a Velocity template as a service parameter (of the HTML type) which is actually the body of an email you try to send. Since you using a velocity template you need to evaluate it first by providing also model objects you use in the template.

    import com.avoka.core.util.StringTemplate

    def model = [:]

    model['submission'] = submission

    String rawMessage = new StringTemplate(serviceParameters.emailBodyTemplate).merge(model)

    emailService.sendMessage(rawMessage)

    should work

    1. Miroslav Botka

      I did not run and test the code above, but it should help you on how to inject the data extracts into your email template

    2. Matt Chant

      Brilliant!!! Thanks for the help!

    CommentAdd your comment...