Create an App: You can choose to use PowerApps studio for Windows (requires installation)orPowerApps studio for Web for creating an App.
Let’s consider using PowerApps studio for windows. Open the application, click on Newand choose the Phone Layoutunder Start with blank canvas or template:
This opens up a designer screen with a blank App screen at the center.
Add a Textbox and place it at the top of the screen. Set the following properties of the textbox: Color =RGBA(255, 255, 255, 1), Fill =RGBA(0, 119, 255, 1), FontWeight = FontWeight.Semibold, Text =“New Lead”
Add an Editable Form (Under Insert tab > Forms > Edit) to the screen and place it below the Textbox covering the rest of the area:
The Form part in the screen will have an option to connect to data. click on Connect your form to data. On the right hand side, under data sources tab, select the SQL server connection created in the previous step, select defaultand then choose the table New_Leads and click on Connect.
After the connection, set the Form’s Itemproperty to Defaults(‘[dbo].[New_Leads]’).
Form customization part will be open in the right pane where you’ll be able to add the required fields in the App.
Select the required fields from the fields list. The selected fields gets added in your App’s screen.
You’ll be able to re-size the text boxes or input controls if required.
Add another screen to the App (Under Hometab click on New Screen). Select the newly created screen from the left pane and add a Text box control. Set the TextProperty to The lead information was submitted successfully! and Alignproperty to Align.Center.
Now we have 2 screens in the App. You can see the names of the screens in the Left pane.
Select Screen1, click on Add a custom card option at the bottom within the screen.
Add a Text boxcontrol in the new card. Set the Auto Height property of the new text box control to true, and set its Textproperty to this formula: Form1.Error (The text box will show any errors from the form. This also requires the form name to be Form1)
Add a Button control in the card. set the button’s Textproperty to Submit and set the button’s OnSelect property to SubmitForm(Form1); If(Form1.ErrorKind = ErrorKind.None, Navigate(Screen2, ScreenTransition.None)) (This formula tries to insert the data entered to SQL table. If there is any error while writing to SQL, the Error message will be displayed on the app otherwise the screen 2 of the app will be displayed informing the user that write to SQL was successful)
The App is now complete and is able to accept user input and save it in SQL table.
In SQL server, run the following simple query Select * From [PowerApps Test].[dbo].[New_Leads] and no rows will be returned.
Run the App created in PowerApps, enter all the information within the App and click on Submit.
In SQL server, run the same select query (Select * From [PowerApps Test].[dbo].[New_Leads]) again and you’ll find the newly inserted row in SQL:
Microsoft continues to enhance the features and capabilities of PowerApps! Have fun building!