Skip to Content
Menu
This question has been flagged
9 Replies
15479 Views

hi how i can add dynamic data in url of link or button in an email in the marketing campaign automation? 

Avatar
Discard
Author

i have try to use QWeb Template like

<a t-att-href="'https://www.lapa.ch/offerta-guanciale?contact_name=' + object.name + '&email='+ object.email +'&phone='+ object.phone +'&partner_name='+ object.parner_id.name"></a>

but for some reason the email return error

if i write just "'https://www.lapa.ch/offerta-guanciale?contact_name=' + object.name + '&email='+ object.email" work if i add phone not work... im confused.

@Cybrosys Techno Solutions Pvt.Ltd have some idea?

Author

i think the QWeb Template error is for object.phone is not escaped. how can i escape this value in the html of an email?

Author

for some reason i cant add more than 2 params. 2 parms work if i send manually the email or if i send a test but not work if the campaign start

return QWEB Template error when try to send automatically

Best Answer

To add a dynamic URL parameter in a link or button in an email template in Odoo v16, you can use the following steps:

  1. Open the email template that you want to modify.
  2. Select the link or button that you want to add the dynamic URL parameter to.
  3. Click on the "Insert/Edit Link" or "Insert/Edit Button" button in the email editor toolbar.
  4. In the URL field, enter the base URL that you want to use for the link or button, including any static parameters.
  5. Add the dynamic URL parameter to the end of the URL, using the Odoo expression syntax "{{...}}".
  6. Inside the double curly braces, enter the name of the field or variable that you want to use as the dynamic URL parameter.
  7. Save the email template.

Here's an example of how you can add a dynamic URL parameter to a link in an email template:

Let's say you want to include a link to the customer portal for each recipient of your email. You can use the following URL as the base URL for the link:

https://yourdomain\.com/my/customers/portal/

To\ add\ a\ dynamic\ URL\ parameter\ for\ the\ customer\ ID,\ you\ can\ modify\ the\ URL\ like\ this:

https://yourdomain.com/my/customers/portal/?customer_id={{object.partner_id.id}}

In this example, we're using the Odoo expression "{{object.partner_id.id}}" to retrieve the ID of the customer associated with the email recipient. This will dynamically insert the customer ID into the URL for each recipient, so they will be directed to their own customer portal page when they click the link.

Note that the exact syntax and field names may vary depending on your specific use case, so you may need to consult the Odoo documentation or seek further assistance to ensure that your dynamic URL parameter is set up correctly.

Avatar
Discard

Hi, I am trying to follow these steps for the following:
> link to Quotion (portal view) from follow-up automated email in Marketing Automation App (Lead / Opportunity Model)
> link to Worsheet Report (portal view) from Invoice email template.
> link to Quotation (portal view) from follow-up automated email in Marketing Automation App (Sales Order Model)

I cannot seem to get the syntax right, can you provide any advice?

I'd like to do the same but the steps mentioned here don't work. Like other answers in this thread, I also get %7B%7Bobject.partner_id.id%7D%7D as a resulting link whether I use ${ } format or {{ double brackets }} the result is the same. Has something changed in Odoo 17 that doesn't allow for this solution?

Author Best Answer

thx, but from marketing automation email i cant go into html of the email. im miss something? 

EDIT i have found the button for go inside the html of email but when the email is send the html {{ is convertend in html entities.. how can i solve this? 


is the result 
contact_name=%7B%7Bobject.name%7D%7D&phone=%7B%7Bobject.name%7D%7D&email=%7B%7Bobject.email%7D%7D&partner_name=%7B%7Bobject.parent_id.name%7D%7D

Avatar
Discard

I'd like to do the same and I also get %7B%7Bobject.partner_id.id%7D%7D whether I use ${ } format or {{ double brackets }} the result is the same. Has something changed in Odoo 17 that doesn't allow for this solution?

Best Answer

@LAPA Zero, 

I'm trying to do the same thing, and here's the problem: 

There's two different types of email templates in Odoo

  1. Email marketing - these are used for mass mailings to your customer in the Email Marketing tool
  2. Mail templates - these are used for single emails for server triggered mailing (eg QWeb)

These aren't the same.  

Unfortunately, Email marketing doesn't support Jinja fields, and Mail Templates (like QWeb, don't support Jinja fields.  

Sorry, what your asking for isn't possible, even in today's Odoo online OOTB.  You would have to get a premium account with access to odoo_sh and customize it.  

Avatar
Discard
Best Answer

simply looking for a way to link to current record via the email template. 

This doesn't seem to work either. 

<div style="margin: 16px 0px 16px 0px;" data-oe-version="1.0">

    <a t-att-href="ctx.get('https://XXXXX.odoo.com/odoo/plm/2/action-1087/{{object.id}}')" style="color: #374151; border-style: none; margin: 0px; box-sizing: border-box; border-width: 0px; background-color: #875a7b; padding: 8px 16px; text-decoration: none; border-radius: 5px; font-size: 13px;"><font style="color: #ffffff;">

        Validate my account&nbsp;</font></a>

</div>

Anyone figure out how to create a dynamic link to a record in an email template? I'm in Odoo 18...

Avatar
Discard
Best Answer

Perhaps use a method to retrive the values you want?

In Odoo 18:

<t t-set="desired_value" t-value="object.your_method_retrieve_url()"/>

<a t-att-href='desired_value' t-out="desired_value" />

I solved my problem this way

Thanks

Avatar
Discard
Best Answer

How is an issue posted about Odoo v16 stil a problem in v17

Did anyone figure it out?

Avatar
Discard
Best Answer

First time User.. Can't delete this yet. I though I was commenting not answering... My bad.. 

I'd like to do the same and I also get %7B%7Bobject.partner_id.id%7D%7D whether I use ${ } format  or {{ double brackets }} the result is the same. Has something changed in Odoo 17 that doesn't allow for this solution?

Avatar
Discard
Best Answer

The way to achieve this is by going to the mail template, 

highlight the word / sentence you want to link, 

Click on the link option, and paste your link with the dynamic field props like  
${object.id}

e.g

/web#id=${object.id}&action=2401&model=approval.request&view_type=form&cids=&menu_id=1160

Avatar
Discard
Best Answer

Hi,

In the email template, in 

<field name="body_html" type="html">

You can give any html content you want for the body of your email.

<div style="margin: 16px 0px 16px 0px;">
<a t-att-href="ctx.get('token_url')"
style="background-color: #875A7B; padding: 8px 16px 8px 16px; text-decoration: none; color: #fff; border-radius: 5px; font-size:13px;">
Validate my account
</a>
</div>

The above mentioned code is the button you see for the email sent when validating account. In the t-att-href, you can give the dynamic value you want.

Regards

Avatar
Discard
Related Posts Replies Views Activity
1
Mar 25
1882
1
Dec 24
668
2
Jul 24
1523
1
Apr 24
955
0
Sep 24
950