Announcement

Collapse
No announcement yet.

Formula script Variables in templates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Formula script Variables in templates

    Hi team,

    I know this has come back over the years: the ability to use variables in email and PDF templates.

    It is a function that I am hoping to have regularly. But it seems impossible.

    What I would like to be able to do is pass a variable from a formula to the applyTemplate: https://docs.espocrm.com/administrat...lapplytemplate.

    Having to create fields in the record for any possible variable that I want to parse in the template is just cumbersome. It creates a lot of extra fields that I don't otherwise need in the record.

    Or am I overlooking a possibility to do this?

    Regards,

    Maarten

  • #2
    Hi Maarten,

    Not possible. The function does not have a parameter to pass additional key => value data.

    But you can modify the email body in the formula script.

    After you applied the template to the email, read the body from the email using record\attribute. Then replace your custom placeholders using string\replace. Then update the email record using record\update.

    Comment


    • #3
      Hi yuri,

      I have the same question as Maarten and a follow-up question to your answer. I understand the way you described it like this: in an email template, I create placeholders, for example in the form $$id1, then I use record\attribute and string\replace to replace my placeholders with the desired values. Finally, I save my changes using record\update

      This works for the first run, but what happens on the second run, since, as I understand it, all the original placeholders have been replaced with values? Or am I missing something?

      Thanks for your support!

      Michel

      Comment


      • rabii
        rabii commented
        Editing a comment
        even on subsequent runs it will still work. the system will always replace the placeholder from content passed through the variable in the script.
    Working...
    X