Community Commons field substitution issue

1
I am using the CommunityCommons.SubstituteTemplate2 java call to substitute some attribute values in a notification template, which works fine most of the time. However, if the attribute value being substituted contains a dollar sign ($) I get an error Caused by: com.mendix.core.CoreException: Exception occurred in microflow 'SLA.Perform_FieldSubstitutions' for activity 'Call 'SubstituteTemplate2'', all database changes executed by this microflow were rolled back ... 1 more Caused by: com.mendix.core.CoreException: java.lang.IllegalArgumentException: Illegal group reference at iw.b(SourceFile:167) Caused by: java.lang.IllegalArgumentException: Illegal group reference Is there a solution to this issue?
asked
2 answers
1

Looked into it, this is a bug in the community commons module. You can apply the following patch to solve this (patch will be included in the next release as well):

replace javasource/communitycommons/StringUtils.java lines 93-97:

if (match.group(1) != null)
    value = String.valueOf(Core.getConfiguration().getConstantValue(path));
else
    value = ORM.getValueOfPath(context, substitute, path, datetimeformat);
regexMatcher.appendReplacement(resultString, HTMLEncode ? HTMLEncode(value) : value);

by

if (match.group(1) != null)
    value = String.valueOf(Core.getConfiguration().getConstantValue(path));
else
    value = ORM.getValueOfPath(context, substitute, path, datetimeformat);
value = Matcher.quoteReplacement(value);
regexMatcher.appendReplacement(resultString, HTMLEncode ? HTMLEncode(value) : value);

(only the 5th line changed)

answered
0

It looks like $ is a special character. Try to escape it, maybe '\$'

answered