If the user enters 9 digits: 01202345678 I need it to be changed to 10202 345678 (5 characters + space + 6 characters)
The problem is to know where to enter the code.
The On Validate is not good as if the field is changed by code, it triggers the code again.
I can run the code after leaving the record bit is it possible to do it as the user is entering more data?
My code works only if the user enters 9 characters and no space but not if they enter the 5 space 6 format, it then errors.
Function: formatphonenumber(phonenumber : Text[30]) : Text[30]
space := COPYSTR(phonenumber,6,1);
IF space <> '' THEN BEGIN
five := COPYSTR(phonenumber,1,5);
six := COPYSTR(phonenumber,6,18);
NewNumber := five + ' ' + six;
EXIT(NewNumber)
END ELSE
EXIT(phonenumber);
Experience is what you get when you hoped to get money
0
Answers
1. Regular expression to match user input against your format (let users to enter phone number in right format)
2. Use addon to show required pattern and lead users to fill it
I like the idea of using regular expression to do this, I would think OnValidate would be the place to do this, I don't understand why that would not work.
There are plenty of instructions online on how to format phone numbers in .NET , for instance I would think the c# example in the following link would be plug and play in Nav.
https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch04s02.html