Hi Remco,
The SubstringExtractor would indeed be the way to go. However if you want to test multiple variables, then it might be more useful to use a PythonCaller, loop through all variables and shorten those that are too long. Below you can find an example.
import fme
import fmeobjects
# Change the value beneath
maxLengthValue = 20
# Template Function interface:
def shortenValues(feature):
# Retrieve all attributenames of this feature
attributes = feature.getAllAttributeNames()
# loop through all attributes
for cAttribute in attributes:
# Make sure nothin is changed on the standard (hidden) fme variables
if cAttribute[0:4] == 'fme_':
continue
# Get the value if this attribute
value = feature.getAttribute(cAttribute)
# Check if the value of this attribute is too long.
if len(str(value)) > maxLengthValue:
feature.setAttribute(cAttribute, value[0:maxLengthValue])
The benefit of using Python over the SubstringExtractor is that you can generate a message in the log so you know a certain attribute is shortened and that you can shorten a lot of attributes with just one transformer.
Good luck!