Set string variable with %20 injects unwanted null

In the example below you will see that I am sending a message to my Sharptools installation.

I have a local variable setup - KitchenStatusMessage. When I set its initial value it works fine. When I try to set it in the rule - you can see that I am getting an errant null in the string.

I have tried deleting the statement, recreating it in a number of ways but can't figure out how to get around this?

Each variable should have a beginning and ending percent sign denoting it as a variable.
You wrote:
This%20is%20a%20test

Instead try:
This %20% is %20% a %20% test.

Good luck.

1 Like

I've had to work around this quirk before. Since Rule Machine wants to treat everything between two percent signs as a variable, it thinks you're trying to use a variable called %20is% when it sees the first two percent signs. That variable is null. So

This %20is% 20a%20test
turns into
Thisnull20a%20test

What you need to do is create a local string variable and set it to "%20", then use the variable substitution to insert that into your other variable like this:

I created a variable called "pct20":

image

Then in the rule I set the variable "test_string" to:
This%pct20%is%pct20%a%pct20%test:

image

As you can see, that sets test_string to the URL encoded string value that you want.

1 Like

Thanks - it would have taken me a month of Sundays to figure that out!