Runtime property - trigger for refresh?

Hi,

I want to validate the format of an input field, i.e. check that the input has exactly four digits.

To achieve this I’m using a runtime property based on a runtime only object class with one record. The runtime property is of data type boolean and property type function. It contains a simple regex validator, which works as expected.

The problem I’m encountering is that the runtime property does not refresh/recalculate when the input, i.e. value of the field I’m checking, is changed. This of course makes the data validation of little use…

So I’m wondering what triggers a refresh/recalculation? Are runtime properties the right way to go to check input using regex or are app variables more reliable?

Many thanks in advance.

Hi!

Thank you for posting this issue to our Community.

Runtime properties are intended to refresh when the data itself changes, so a runtime property is definitely a good approach in this case. I initially thought this could be a problem related to a regex validator, however I have tried to recreate the issue and it works as expected in my environment.

Here is my formula for a runtime property “valid” based on the string “input text”, to check if the string is 4 letters long:
image

And here is the output:
image
image

To avoid the use of regex entirely, you could also check the length of the input by using this formula instead:
return <yourVariableNameHere>.length() == 4

If the issue still persists where the runtime property doesn’t update despite the data changing, could you provide some more details on your exact setup so that we can investigate further?

Rhys

Hi,

thanks for the reply.

When you enter a input that results in “False” and then change it so that it should result in “True”, does the result on your end change immediately? For me the update is sort of iratic…

Check out the screen recording:

Hi,

Yes it does! Here is the screen recording on my end:

I have the “Update on Keypress” property ticked on the Text Edit component, which you could maybe check if you have enabled too?
image

Rhys

Yes, Update On Keypress is activated. Still does not update.

Even in the developer tools I get this, i.e. the value is 4 digits but the runtime property shows the result of the regex as “False”:

I only get the runtime property to update when I select the content of the field and quickly replace it with another string that is not the continuation of the prior string, i.e. when i replace 111 with 2222, but not when I replace 111 with 1111. And if the values are entered too slowly, i.e. first enter 11, wait 1 second, enter 22 so that the input is 1122 the result is False…

Does this happen on several different browsers, or several different devices? From the screen recording you sent, it looks like the runtime property update is delayed somehow, that you need to change it twice for the first change to take effect. If there are lots of different runtime properties being recalculated at the same time, or if there are several other places that reference “Bygning adresse postkode”, this could affect the performance of the runtime property calculation.

One (not ideal) alternative is to copy the existing formula and then to change the type of the runtime property to Value instead of Function. You could then connect an action to the On Value Change event handler for the text edit. In this action, you can use an Update Object action node and paste the function into the runtime property field there. This will update the runtime property manually each time the value in the Text Edit changes.

Rhys

Hi!

Just a quick sidenote: A quick way to check is the function (behind “Gyldig postkode - bygning”) is reevaluated when the input is changed, add some “console.log” statements before the return statement in the function, such as this:

var pattern = new RegExp(/^[a-zA-Z]{4}$/)
console.log("Input text is: " + inputText)
console.log("Evaluation: " + pattern.test(inputText))
return pattern.test(inputText)

In many cases, the evaluation happens, but there is some errors in the code itself. Not saying that’s the case, but worth checking!

Yes, same result on Firefox as in Chrome. Yes, seems like runtime properties aren’t that robust. Will use actions instead…