3

I'm creating a dynamic template in SendGrid. I want to change the color of a field based on a field in my case Success.

For example, this is my json.

{
    "Environment": "[DEV] ",
    "RunAtTime": "09/06/2020 11:29:02 +01:00",
    "Status": "Success",
    "OrganisationId": "6",
    "OrganisationName": "Test",
    "InvoiceId": "2",
    "InvoiceRef": "Acme Ltd., A1 Taxis",
    "Amount": "50.00"
}

Following the documentation, I tried to do something like

{{#if this.Status = 'Success'}}
#00b300
{{else}}
#ff0000
{{/if}}

I found example only for boolean field.

My goal is to change the text color based on a field. What is the best way to do that?

Enrico
  • 3,592
  • 6
  • 45
  • 102

1 Answers1

3

Sendgrid doesn't allow to check strings like this Please modify code as below

{{#equals this.Status "Success"}}

Reference link for other conditions statements: https://sendgrid.com/docs/for-developers/sending-email/using-handlebars/#conditional-statements

larry
  • 31
  • 4