Email body based on Form data

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Email body based on Form data

PiotrW
Hi

I'm trying to generate emails from Orbeon which body contains data taken from the form.

I modified (overrrided) email-form.xpl to choose correct body from resources.xml (which was also changed).

Mail subject and body is choosen right now only by application  name so I use  variable app already existing at email-form.xpl

To get the data from the Form to the email body I use replace() function,

And it works fine - I can select proper body and do replacement of needed element to get in the body data from the form

But I got the problem when I tried do more than one replacement on the email body - I got the same body in the message twice each for one replacement.

I attached the code of modified email-form.xml and resources.xml - You can see in the "body" part I do replacement twice  - to replace LINKTOREPLACE and ANNOTATIONS  by the data from the form.

email-form.xpl
resources.xml

And in this case I got mail like this bellow (with doubled body):


Dear User
                                                       
Please fill the rest of the form using following link
http://xxxxx/orbeon/fr/NewSupplierForm/NewSupplierForm/new?input-parametr=123
                                                                                                               
ANNOTATIONS
best regards -  ORBEON Team
                                                       
Dear User
Please fill the rest of the form using following link
LINKTOREPLACE
annotation informations to the user
best regards -  ORBEON Team


I can not find out how to get only email body ones, with all replaced values...

I've tried to find any answer in the discussion topics, but the only one, quite similar http://discuss.orbeon.com/Configurable-email-body-td4659587.html#a4659616
has not give me any answer how to get only one body with several replacements.

If it would have been any solution, then I'd might had possibility to enter as many fields from the form on the email body...

looking forward  for any help...

best regards

PiotrW

Reply | Threaded
Open this post in threaded view
|

Re: Email body based on Form data

Alessandro  Vernet
Administrator
Hi Piotr,

In email-form.xpl, you're doing:

<xsl:value-of select="replace($emailbody, 'LINKTOREPLACE', $SubjectUrlCustom-values)" />
<xsl:value-of select="replace($emailbody, 'ANNOTATIONS', $FormAnnotations-values)" />

This will indeed output the email body twice, the first time with the first replacement, and the second time with the second replacement. Instead, I think you want to write something like:

<xsl:variable name="link-replaced" select="replace($emailbody, 'LINKTOREPLACE', $SubjectUrlCustom-values)" />
<xsl:value-of select="replace($link-replaced, 'ANNOTATIONS', $FormAnnotations-values)" />

You'll let us know if this works for you,

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Email body based on Form data

PiotrW
Hi Alessandro

Thanks for Your suggestion and solution

Now it works as I would like to be - we can get data from Form fields to the email body.


best regards

PiotrW

Reply | Threaded
Open this post in threaded view
|

Re: Email body based on Form data

Alessandro  Vernet
Administrator
Hi Piotr, perfect, and thanks for the update.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet