Skip to main content
Question

SMS and Email Templates

  • December 6, 2019
  • 1 reply
  • 29 views

jessebridge

Hi all,

 

 

I have a scenario where i have many different types of SMS and Email notifications occurring and i want to create a centralized location on the server for these templates to be edited/adjusted as needed without having to dive into the workbenches every time. Is there a way of doing this? i tried reading the message layout from a text file but it does not resolve the '@attributevalue' sections that i want it to.
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

david_r
Celebrity
  • December 6, 2019

FME tries its hardest to be intelligent about resolving @Value() function calls in attributes, but sometimes it doesn't work, e.g. when reading from a text file.

You probably need to break out Python for this, here's a sample workspace with a PythonCaller that will replace all references to @Value(...) with the corresponding attribute value. It assumes that the template to analyze is in the attribute "template" and the result will be output to "template_resolved":

1import fmeobjects
2import re
3
4def expand_fme_macros(feature):
5    input = feature.getAttribute('template')
6    matches = re.findall("@"+"Value\((\w+)\)", input)
7    for group in matches:
8        input = input.replace("@"+"Value(%s)" % group, 
9                              str(feature.getAttribute(group) or ''))
10    feature.setAttribute('template_resolved', input)

(Notice how I have to split up "@" and "Value" into two separate strings in the Python code to avoid FME trying to interpret it literally, that's how hard FME tries to be intelligent about it...)

Test workspace: template_resolver.fmwt


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings