Introduction:
Now, it is possible to build the business apps without having coding experience. Microsoft provide service named PowerApps using which users can build the apps as per the requirement and can run on the Browser, phone and tablets.
With the help of Microsoft PowerApps, we can build the apps that run on browser, tablets and on Phone. PowerApps has three major components:
- Canvas Apps
- Model-Driven
- Common Data Service
In this blog we are focussing on Canvas Apps of Microsoft PowerApps. Canvas apps allow to work with the 200 data sources.
So, let’s create small Canvas app with few controls to create records in Dynamics CRM. Below are the steps to create the records in Dynamics CRM.
1. Sign in to the PowerApps site https://powerapps.microsoft.com/en-us/ with the Microsoft work email id. After signing you will see the below screen:
a. Click on Create an app and it will navigate to another screen. Then select Phone Layout under the blank Canvas blank.
2. A blank screen will appeared as below. You can rename it if you want.
Note: Here we have used scrollable screen and all control placed inside sections. You can use blank screen.
Add controls from the Insert Tab to the blank screen so that we can take input to save the record in CRM.
Here we are going to create the custom entity (survey) record in CRM. You can use other entity as well.
Set the Min, Max, Default property of slider control.
3. configure the Account Lookup
To set the Account lookup on Survey entity we added another screen to select the Account record
To add blank screen: Go to Insert -> New Screen -> select Blank Screen.
Add Gallery control to display the list of existing Account records in Gallery control.
To add Gallery control; Go to Insert -> select Gallery -> Select Vertical Gallery control.
4. Now set the property for Account Lookup on textbox control.
a. Set On Select property of search icon to
Navigate(AccountLookup,ScreenTransition.Fade,{searchAccName : TextInputSelectAccount_3.Text }) ;Clear(SelectedAccountRecord )
Here we are navigating the screen to select the Account record and also passing the value as SearchAccName of Select Account Textbox.
b. Set the Default property of Select Account textbox to
If(IsBlank(First(SelectedAccountRecord ).account.accountid),Blank(),First(SelectedAccountRecord ).account.name)
Here we are displaying the selected account name from the Account Gallery in the textbox. Initially it will display blank.
5. To select CRM Account Record we added the another blank screen.
Insert – > New Screen
a. Now add Account data source:
Select view -> Data Source – > Select the connection and then add the Account Data Source
b. Now set the Gallery Item Property to
If(IsBlank(searchAccName), Accounts,Search(Accounts,searchAccName,”name”))
Here the Gallery will display the list of the accounts with matching name in searchAccName variable from previous screen. If searchAccName is empty then it will show all accounts.
c. Set On select property of Arrow on BrowsGallery to
ClearCollect(SelectedAccountRecord , {account : BrowseGallery3.Selected});Reset(TextSearchBox3); Back()
Here we are storing the selected account record in the separate collection i.e. SelectedAccountRecord.
6. Set the On select property of Submit button
Here we need to add the Data source for the Custom entity (Survey)
Set the On select property of Submit button to
Patch(‘Survey”s’,Defaults(‘Survey”s’),{new_name:TextInput2Name_2.Text,new_issurveydone : ToggleIsSurveyDone_4.Value , new_noofemployee :Value(Slider1_1.Value),new_email :TextInputEmail_3.Text,new_surveydate : DatePicker1_3.SelectedDate ,new_signature : Signature_1.Image,_new_selectaccount_value:If(IsBlank(First(SelectedAccountRecord).account),Blank(),First(SelectedAccountRecord).account.accountid)});
In Patch function we will set the values of controls to the Survey data source columns.
Note: The pen input control will give BLOB data string and this signature will not be displayed on the Dynamics 365 for Phone app.
Conclusion:
In this way we can create the records in Dynamics CRM with the blank canvas app using Patch function.