Contoso has built a model-driven app to challenge their employees to innovate. The way the app works is Contoso management can submit challenges and then employees can submit ideas. For example, a challenge might be “Reduce factory emissions by 10%.” Employees can submit ideas for challenges and get funded once they get enough votes.
Contoso would like to announce new challenges in Microsoft Teams by posting some information about the challenge. Contoso’s users would like to be able to create this post from the model-driven Innovation Challenge app they use to manage the challenges.
You will be building an embedded canvas app that will let users start discussions without leaving the Innovation Challenge application.
The lab requires a PowerApps environment with a Common Data Service database created and the sample apps installed.
The following have been identified as requirements you must implement to complete the project.
R0 – User must be able to start new Teams discussion from the existing Innovation Challenge application.
R1 – User must be able to select the Team in which they would like to start the discussion.
R2 – User must be able to select the Channel in which they would like to start the discussion.
R3 – The Challenge name must be included in the chat message.
R4 – User should be able to edit the message before posting it.
R5 – The embedded canvas should not be visible if a discussion was already started.
Exercise 1 – Canvas App in Model-Driven App
Task 1: Connect to Teams
In this task, you will add a Microsoft Teams trial to your tenant (if needed) and create a couple Teams and channels.
Enter Contoso Embedded for Display Name, click on the Publisher dropdown and click + Publisher.
Enter Contoso for Display Name, contoso for Prefix and click Save and Close.
Select Contoso for Publisher, enter 18.104.22.168 for Version and click Create.
Click to open the solution you just created.
Click Add Existing and select Entity.
Select the Challenge entity and click Next. If you have difficulty locating the Challenge entity, use the search box to find and select it.
Click Select Components.
Select the Forms tab.
Select all three forms and click Add. Note: Ideally we would just select the Main Form that we are going to edit, however due to a current bug that type of form is not showing and all three forms are named Information.
Click Add again.
Click to open the Challenge entity.
Select the Fields tab and click Add Field.
Enter Started Date for Display Name select Date Only for Data Type and click Done.
Note: Currently Embeded Canvas Apps can only be created as a control for a field or a subgrid, you can’t just put a canvas app unbound to any data.
Click Save Entity.
Task 3: Add Field to the Form
In this task, you will add the new field to the main form.
Select the Forms tab.
Hover over the Main form, click on the … More Commands and select Edit Form (Preview).
Select the Contributed Ideas section.
Click Add Control and select 1-Column Section.
Go to the Properties pane, change the Section Label to Start Team Chat, change the Name to start_team_chat_section.
Click Add Field.
Select Started Date.
Click Switch to Classic. Note: Currently, you can only create the embeded canvas app and change the controls for a field from the classic form editor. In the future you will be able to do this without changing to classic.
Do not navigate away from this page
Task 4: Add Canvas App
In this task, you will create the canvas application. Since you are working in a solution, the canvas app you create here will also be included in the solution.
Double click the Started Date field. In some browsers you may need to select the item and look for form properties in the header instead.
Uncheck Display Label.
Select the Controls tab and click Add Control.
Select Canvas App and click Add.
Click Customize to create your canvas app in the PowerApps Studio. This will launch an app designer browser tab.
Click File and select Save.
Enter Start Group Discussion for Name and click Save.
Click on Back button in the PowerApps console (not the browser back button).
Right click on Form1 and select Delete.
Rename the Screen teamsScreen.
Select the View tab and click Data Sources.
Go to the Data pane and click Add Data Source.
Select Add New Connection.
Search for Teams and select Microsoft Teams.
Click Add Data Source again.
Search for Common Data Service and select it.
Select the Challenges entity and click Connect.
Close the Data pane.
Select the Insert tab, click Controls and select Drop Down.
Right click on Dropdown1 and select Rename.
Rename it teamsDropdown.
Set the Items property to the formula below. If you have difficulty with copy/paste then type the formula manually. This formula will list the available teams in the dropbox
Go to the Properties pane and click Advanced.
Scroll down to the Data section and select displayName for Value.
Click Controls and select Dropdown again.
Rename the dropdown channelsDropdown.
Set the Items property to the formula below. This formula will show the channels of the selected team in the second dropdown.
Select Solutions and open the solution you created.
Select Apps, select the Start Group Discussion application, and click Edit.
Select the Start Discussion button.
Select the OnSelect property, place your cursor at the beginning of the existing function and paste the formula below. There are two functions in this formula, the Patch function will update the Started Date of the Challenge records and the ModelDrivenFormIntegration.RefreshForm will refresh the form.