Doc merge Javascript

Hello, All

I have a question concerning Doc merge template

I am trying to show different text depending on if a field conntains a specfic word

I have followed the documents and saw something like this:

Example

This example will show the dp_business_purpose field in the Contacts module if the business purpose contains the word "Marketing". If you do not see this field in your contact's record view, you may need to add it to the layout in Studio.

{if (dp_business_purpose.filter(item=>item.includes("Marketing")).length>0)}
{dp_business_purpose}
{else}
NONE
{endif}

it seems like it is using javascript syntax.

I tried using includes on a string but it gives an errror "un expected token"

so, my question would be, how do I go with implemening this?

any help would be apprciated

  • Hello  

    For your scenario I believe the best is to use the formula builder that you can find in the Template Assistance. 

    Taking your specific requirement you can consider a formula like bellow that will print one of two messages depending if the string "test" is present in the description: 
    {!formula value='ifElse(contains($description,"test"),"Description has a test","no test was found here")'}

    Let me know if this is what you are looking for.

    Cheers, 

    André