Using “%” character in notification within RM?

Wondering if anyone knows of a better way to do this.

I am trying to use a “%” character in 2 spots within a notification. This is not working because it is set to recognize %variable% and convert this value to the variable’s value. This leads to (First % underlined in red. Second % underlined in yellow):

I first tried to replace the first “%” character with &#37, but this got automatically replaced with the above screenshot after leaving the message edit box:

I ended up placing the “%” character in a string variable which I added to the Message box and this worked. However, I wonder if this is the best approach. Does anyone know of another way to do this that wouldn’t require an extra variable?

Here is a screenshot of the approach that works:

With the following variable:

I can reproduce this issue. I just made a simple rule to write to the Log as shown below.

Your workaround works. But is this a bug in string handling? Or expected behavior? @bravenel

Take your pick.

Don't know if this is feasible, but would it be possible to add "\" as an escape character in Rule Machine for strings?

1 Like

An escape character would be useful for situations like this. However, I’ve never seen this reported as an issue, so not sure there’s much value in implementing it considering there is a workaround… If it does get implemented though, I’ll use it! :blush:

1 Like

I have no problem with this. This rule:

produces these logs:

Looking at @aaiyar's example above, the first case is certainly going to fail as the code will interpret the second % as matching the one after that, looking for " and Decimal is". That's a pretty narrow edge case, not worth wasting any effort on.

Exactly. It works when there is only one % after the last variable. The workaround of using a variable to store the % works for those edge cases.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.