FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    How can I get the client_id in my email template?

    Scheduled Pinned Locked Moved
    Q&A
    email freemarker templates
    1
    2
    1.0k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • danD
      dan
      last edited by dan

      I'm doing some email template configuration to add some conditional statements by application_id, to customize the email by application. In the FreeMarker template, I added a hash with the values I need for each application, and at the top of the template, I create a clientId variable to use as my index.

      [#assign clientId = state.client_id?string!"dafb6ef6-a2a8-4d34-9d69-59bfed3e31aa" /]
      

      This works in some emails, but in others I get an error that the state doesn’t exist, so I can’t reference state.client_id.

      Is there a more straightforward way to get to client_id in an email template, so the default operator ! will work here if it doesn’t exist? Or is there a way to do some check on state first, and go straight to a default value if state doesn’t exist?

      --
      FusionAuth - Auth for devs, built by devs.
      https://fusionauth.io

      1 Reply Last reply Reply Quote 0
      • danD
        dan
        last edited by

        I figured it out…. I just had to put state.client_id in parens so it resolved them together.

        [#assign clientId = (state.client_id?string)!"dafb6ef6-a2a8-4d34-9d69-59bfed3e31aa" /]
        

        --
        FusionAuth - Auth for devs, built by devs.
        https://fusionauth.io

        1 Reply Last reply Reply Quote 0
        • First post
          Last post