on 07-14-2020 7:40 AM
Hi Experts,
I have a requirement where the input should not be more than 5 characters in a Simple Property control.
In the OnValueChange event I have added a rule with the code below.
var context;
export default function InspectionShortTextValidation(context) {
// Making the inspection short text not to exceed 5 characters
var inspectionShortTextValue = context.getValue();
var maxLength = 5;
if (inspectionShortTextValue.length > 5) {
var trimmedValue = inspectionShortTextValue.substring(0, maxLength);
context.setValue(trimmedValue);
}
}
Although it works, there seems to be a scenario where the event does not get triggered.
For an example when I type in '123456', it triggers the event and changes the string correctly to '12345', which causes the event to trigger again as the value was changed from the code although it is not a user input. But when I try to add '6' again, the event does not get triggered for some reason and it keeps '123456' as a valid input. I need to do another change in order to trigger the event.
How can I avoid this please. Is the way I am doing it wrong? or is there a way I can identify if the change was causeed from a user input or from a code?
Thank you.
This seems to be a bug, if you try following sequence which means 12345, then 6, then 7 and so on it works. But the moment you have 12345, then 6, then 6 it fails the second time. We will report this to the dev team.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When you call setValue to put the trimmed value back into the field you can also specify a second (optional) parameter to indicate if the setValue should notify the control that the value changed. This allows you to set a value from a rule where you don't want OnValueChanged to trigger.
context.setValue(trimmedValue, false);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.