I am creating a PowerApp form for a SharePoint List with two fields I want to have data validation on. I use the required property of each field and have tried both of these formulas:
If(IsMatch(DataCardValue6.Text,"\d{7}") = false, true, false) - I tried this without the if statement as well and it did not work. This field is simply a 7 digit number #######.
If(IsMatch(DataCardValue11.Text, Match.Digit & Digit & Digit & Match.Hyphen & Digit & Digit & Digit & Digit & Digit & Match.Hyphen & Digit & Digit & Digit & Digit & Match.Hyphen & Digit & Digit & Digit)=false, true, false) - Also tried without the if statement. This is supposed to be a number formatted ###-#####-####-###.
I made the field required on the list, then made it not required, and both are limited in character length on the SharePoint list. The problem I am having is I can save the record when I put alpha characters into the field. What was also weird is when I tried to use the type ahead with the field name, it only had "ThisItem.Fieldname" and would not let me append it with ".Text." This is why I used the DataCardValue# info.
Solved! Go to Solution.
So I got it to work. The formula I used needs to be on the Update property. I used this formula and it's variant for the other field.
If(IsMatch(DataCardValue11.Text,"\d{3}-\d{5}-\d{4}-\d{3}"),DataCardValue11.Text)
I go the info from this article.
https://wonderlaura.com/2019/07/23/powerapps-text-input-pattern-validation/
Thank you everyone.
Example:
1234567
Formula:
IsMatch(Label1.Text,"\d{7}")
Result:
True
Example:
1234567
Formula:
Not(IsMatch(Label1.Text,"\d{7}"))
Result:
False
Example:
333-55555-4444-333
Formula:
IsMatch(Label1_1.Text,"\d{3}-\d{5}-\d{4}-\d{3}")
Result:
True
Use these as your validation before saving the record.
Sorry I have been off work the last couple of days. I put the formulas you gave me in the required property for each of my 2 fields. Use the Not() function got the required asterisk to disappear when the pattern was matched, but I am still able to save a new record with random text characters entered. It is not "validating" to numbers only.
I don't know if this matters, but I noticed I didn't specify this earlier. These are SharePoint List forms customized in PowerApps. I am using the buttons on the SharePoint List (New, Save, Cancel) that are built into the SharePoint List.
So I got it to work. The formula I used needs to be on the Update property. I used this formula and it's variant for the other field.
If(IsMatch(DataCardValue11.Text,"\d{3}-\d{5}-\d{4}-\d{3}"),DataCardValue11.Text)
I go the info from this article.
https://wonderlaura.com/2019/07/23/powerapps-text-input-pattern-validation/
Thank you everyone.
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
206 | |
188 | |
78 | |
49 | |
37 |
User | Count |
---|---|
315 | |
261 | |
121 | |
73 | |
58 |