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.
I have used the data extract for all the fields required
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.
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.
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.
def model = [:]
model['submission'] = submission
String rawMessage = new StringTemplate(serviceParameters.emailBodyTemplate).merge(model)
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
Brilliant!!! Thanks for the help!