Forum Discussion

pp_01's avatar
pp_01
Mentor
6 years ago

Getting SLE value in Email Template using Velocity

Hey all.

I want to get one of the setting's values given in the Settings List Editor in the email templates and then after getting the value, I have to customize the template's content. How can I call the setting using Velocity variables and context objects?

If anyone knows anything about this then please let me know. Thanks in advance.

 

  • pp_01,

    There is no context objects for "Settings List Editor" values. We can fetch the values using API v1 and v2, but this will not help in you case.

    • pp_01's avatar
      pp_01
      Mentor

      Hey Parshant. Thanks for the reply.

      1. So if I can get the values using V1 or V2 is there any possibility that by writing them in the template HTML, can I get the data and do what is required? Actually, I have to get some comma separated values from the settings and then if any of these values match some other values already present in the template code I have to run some freemarker code. 

      2. While looking for answers, on the page in the studio where we see email templates I have stumbled upon two things or settings SettingByNameTemplateWrapper and SettingsByNameLocalTemplateWrapper both stating :

      get(settingName)
      Returns a setting value by name
       

      Now I don't know if you have worked on Velocity but if you think that these will work and there is a way (a snippet basically as I am using it the wrong way) I can use them and if you can share it with me then that will be very helpful to me.

      • snaffle's avatar
        snaffle
        Expert

        We've done some quite extensive customisations of the email template but as far as I know there's no way of running Freemarker inside them, you're limited to the available context objects which can you view underneath the templates themselves in Studio... Related discussion here - https😕/community.khoros.com/t5/Developer-Knowledge-Base/Email-template-context-objects/ta-p/75924

        One thing we did work out though was that it could be personalised to an extent... we had some custom user profile fields that we wanted to display in the emails which we were able to do by defining a Velocity variable at the start of the template as so:

        #set($user_custom_field = ${user.get("custom.profile.custom_field")})

        We could then display the contents of the custom field in the email body.

        Would really be super useful if there was a way of querying the API in the templates though.