web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Name and Phone Number ...
Power Apps
Answered

Name and Phone Number Check with Phone Validation

(0) ShareShare
ReportReport
Posted on by 209

I am building my first app in Powerapps.

I have a screen where users will register their name and phone number.

On the Register button, I have the displaymode set to disabled until a name and 10 characters are added to their respective fields.

I am struggling on doing a couple of other things which I could use some help with.

1. Forcing the phone number field to be numbers only

2. Perform a check on the phone number entered and if it already exists in my sql datasource, redirect to returning screen.

 

I would really appreciate any advice you might have.

Categories:
  • wyotim Profile Picture
    2,545 on at

    @kevinsrayCongrats on building your first app! 

     

    For forcing the text input to be numbers only, there is a Format field in the Properties section that you can change to Number. Then that text entry will only allow numbers to be used.

     

    2018-08-02 (1)_LI.jpg

     

    One issue with this is that when you reference the text input it in other formulas, PowerApps will still see it as text and you will need to wrap it in a Value() statement to make it a number.

     

    The way I would perform a check would be to filter your table based on the number entered and see if the returned table is empty or not. You could make a hidden text box that returns a true/false based on this, then have an If statement on the submit button to check that and act accordingly. 

     

    Here is a screenshot of what that formula might look like:

     

    2018-08-02 (2).png

     

    The button to submit would have code like:

     

    /* If the filter check is not blank (i.e. the phone number is on the list), 
    go back to the first screen. Otherwise, submit the form. */ If( Label1.Text = false,
    Navigate(FirstScreen, None), SubmitForm(PhoneList) )
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @kevinsray,

     

    Could you please share a bit more about your app's configuration?

    Do you add a SQL table as a data source within your app?

     

    I agree with @wyotim's thought almost. For your first question, if you want to force the Phone number field to be numbers only (Could only type numbers), please take a try to set the Format property of the Phone number field to following formula:

    TextFormat.Number

    For your second question, if you want to perform a check on the Phone number entered, I have made a test on my side, please take a try with the following workaround:2.JPG

    Set the OnSelect property of the "Register" button to following formula:

    If(
    IsEmpty(LookUp('[dbo].[PhoneNumbers]',PhoneNumber=DataCardValue4.Text)),
    SubmitForm(EditForm1),
    Navigate(BrowseScreen1,ScreenTransition.Fade);Notify("The record with the phone number is existed",NotificationType.Warning)
    )

     

    On your side, I assume there is a PhoneNumber field which is a string type field within your SQL table, please set the OnSelect property of the "Resgister" button to following:

    If(
    IsEmpty(LookUp('YourSQLTable',PhoneNumber=DataCardValue4.Text)),
    SubmitForm(EditForm1),
    Navigate(BrowseScreen1,ScreenTransition.Fade);Notify("The record with the phone number is existed",NotificationType.Warning)
    )

     Note: The DataCardValue4 represents the Phone Number field within the Edit form of your app. The BrowseScreen1 represents the returning screen within your app.

     

    If the PhoneNumber field is a int type field within your SQL table, please set the OnSelect property of the "Register" button to following formula:

    If(
    IsEmpty(LookUp('YourSQLTable',PhoneNumber=Value(DataCardValue4.Text))),
    SubmitForm(EditForm1),
    Navigate(BrowseScreen1,ScreenTransition.Fade);Notify("The record with the phone number is existed",NotificationType.Warning)
    )

     

    The GIF image as below:Test1.gif

     

     

     

     

    Best regards,

    Kris

     

  • kevinsray Profile Picture
    209 on at

    Kris,
    Yes, the data is on a SQL Table.

    The Register button is set to displaymode.disabled until both Name and Phone fields are entered, and Phone is 10 characters.

    Once these 2 conditions are met, the displaymode is set to edit.

    Then it does a Patch to the SQL table.

    I am not using a gallery, just a plain screen with Labels and TextInput fields.

    I will try incorporating your suggestion in and let you know if it works.

  • kevinsray Profile Picture
    209 on at

    Kris,

    I have tried, but it doesn`t seem to work.

    The code I have on the Register button at current is as follows:

    Patch('[dbo].[Visitor_Register]',Defaults('[dbo].[Visitor_Register]'),{FullName: NVS_Name_Input_Text.Text,Company: NVS_Company_Input_Text.Text,Phone: NVS_Phone_Input_Text.Text, Email: NVS_Email_Input_Text.Text, VisitorType: "V", WHS: "NA"})
    ;
    Patch('[dbo].[Visitor_Records]',Defaults('[dbo].[Visitor_Records]'),{FullName: NVS_Name_Input_Text.Text,Company: NVS_Company_Input_Text.Text,Phone: NVS_Phone_Input_Text.Text, Email: NVS_Email_Input_Text.Text, CheckIn:
    DateTimeValue( Text( Value( Now() ), "[$-en-US]mm/dd/yyyy hh:mm:ss") )})
    ;
    Navigate(CheckedInScrn,ScreenTransition.Fade)

    This will send the data to 2 SQL Tables, and go to CheckedInScrn.

    The code I tried was:

    If(IsEmpty(LookUp('[dbo].[Visitor_Register]',Phone=NVS_Phone_Input_Text.Text)), Patch('[dbo].[Visitor_Register]',Defaults('[dbo].[Visitor_Register]'),{FullName: NVS_Name_Input_Text.Text,Company: NVS_Company_Input_Text.Text,Phone: NVS_Phone_Input_Text.Text, Email: NVS_Email_Input_Text.Text, VisitorType: "V", WHS: "NA"})
    ;
    Patch('[dbo].[Visitor_Records]',Defaults('[dbo].[Visitor_Records]'),{FullName: NVS_Name_Input_Text.Text,Company: NVS_Company_Input_Text.Text,Phone: NVS_Phone_Input_Text.Text, Email: NVS_Email_Input_Text.Text, CheckIn:
    DateTimeValue( Text( Value( Now() ), "[$-en-US]mm/dd/yyyy hh:mm:ss") )})
    ;
    Navigate(CheckedInScrn,ScreenTransition.Fade),Navigate(ReturnGuestScrn,ScreenTransition.Fade);Notify("You appear to already be registered",NotificationType.Warning))

    But it gives me the message saying I am already registered, even though the Phone number does not exist in SQL and is a nvarchar data type

    I am guessing I am missing something small somewhere, but not quite sure.
    Thank you in advance for your help.

     

     

     

     

     

     

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @kevinsray,

     

    Please take a try to re-fresh your SQL table within your SQL Server Management Studio manually, then check if the phone number has been existed within your SQL table.

     

    In addition, please take a try to add a Label control within your app and set the Text property of the Label control to following formula:

    IsEmpty(LookUp('[dbo].[Visitor_Register]',Phone=NVS_Phone_Input_Text.Text))

    then check if the Label control display true or false. If the Label control display false, it means that the Phone number is existed in your SQL table.

     

     

    You could also take a try to type another different phone number within the NVS_Phone_Input_Text Text input control, then click the "Register" button again to check if the issue still exists.

     

    Best regards,

    Kris

  • kevinsray Profile Picture
    209 on at

    Kris,
    I am not sure I if just fluked it, but after a little testing, I found that using IsBlank, instead of IsEmpty, seems to do the job perfectly.

    Not sure exactly what the difference between these 2 are, but it seems to work, so I think I am happy.

    I will do some more testing and double check.

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @kevinsray,

     

    The IsBlank() function is used to detect if a value is blank. The IsEmpty() function is used to detect whether a table contains any records.

     

    The LookUp() function is used to find the first record in a table that satisfies a formula, so you should use IsEmpty() function to detect if the result the LookUp() function returned is empty.

     

    If you want to use IsBlank() function within your formula, please modify your formula as below:

    If(
    IsBlank(LookUp('[dbo].[Visitor_Register]',Phone=NVS_Phone_Input_Text.Text).Phone),
    Patch('[dbo].[Visitor_Register]',Defaults('[dbo].[Visitor_Register]'),{FullName: NVS_Name_Input_Text.Text,Company: NVS_Company_Input_Text.Text,Phone: NVS_Phone_Input_Text.Text, Email: NVS_Email_Input_Text.Text, VisitorType: "V", WHS: "NA"}); Patch('[dbo].[Visitor_Records]',Defaults('[dbo].[Visitor_Records]'),{FullName: NVS_Name_Input_Text.Text,Company: NVS_Company_Input_Text.Text,Phone: NVS_Phone_Input_Text.Text, Email: NVS_Email_Input_Text.Text, CheckIn: DateTimeValue( Text( Value( Now() ), "[$-en-US]mm/dd/yyyy hh:mm:ss") )});Navigate(CheckedInScrn,ScreenTransition.Fade),
    Navigate(ReturnGuestScrn,ScreenTransition.Fade);Notify("You appear to already be registered",NotificationType.Warning)
    )

    More details about IsEmpty function and IsBlank function in PowerApps, please check the following article:

    IsEmpty function, IsBlank function

     

    Best regards,

    Kris

  • kevinsray Profile Picture
    209 on at

    Kris,
    Thank you very much for this explanation.

    As the database has other records, I am guessing that is why the IsEmpty function didn`t work.

    Or maybe I just got lucky.
    Anyway, my function test is fine and it is working as expected, so all is good.

    Thank you once again.

    Now for my next post...

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard