M04 - HOL Embedded Canvas
M04 - HOL Embedded Canvas
Hands-on Lab
Table of Contents
Lab Overview..................................................................................................................................................................... 1
Environment .................................................................................................................................................................................. 1
Scenario ............................................................................................................................................................................................ 1
Requirements................................................................................................................................................................................. 1
Exercise 1 – Canvas App in Model-Driven App .................................................................................................................... 2
Task 1: Create connection to Microsoft Teams ............................................................................................................... 2
Task 2: Add Field .......................................................................................................................................................................... 5
Task 3: Add Field to the Form ................................................................................................................................................ 6
Task 4: Add Canvas App ............................................................................................................................................................ 8
Task 5: Test the Application ..................................................................................................................................................18
Lab Overview
Environment
The lab requires a new PowerApps environment with a Common Data Service database created
and the sample apps installed.
Scenario
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.
Requirements
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 they would like to start the discussion in.
• R2 – User must be able to select the Channel the would like to stat the discussion in.
• R3 – The Challenge name must be included in the chat message.
• R4 – User should be able to edit the message before posting it.
1
Advanced Canvas- Lab Overview
6) Select Public.
7) Enter Team One for Name and click Create.
8) Click Skip.
9) Click Manage Teams again.
10) Click Create a Team.
11) Select From Scratch.
12) Select Public.
13) Enter Team Two for Name and click Create.
3
Advanced Canvas- Lab Overview
17) Add another Channel to Team One and name it Channel Two.
18) Add two Channels to Team Two and name them Channel One and Channel Two.
19) You should now have two teams and three channels for each team.
5
Advanced Canvas- Lab Overview
5) Enter Send to Teams for Display Name select Text 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. We are therefore creating a
Send To Teams field to track if we have posted to teams, but also to allow us to display the
custom visual.
5) Go to the Properties pane and change the Section Label to Start Team Chat.
7
Advanced Canvas- Lab Overview
8) Click Save.
9) Click Publish.
10) Click Switch to Classic. Note: Currently, you can only create the embeded canvas app and
change the controls for a field form the classic form editor. In the future you will be able
to do this without changing to classic.
5) Select Web.
6) Click Customize to create your canvas app in the PowerApps Studio. This will launch an
app designer browser tab.
9
Advanced Canvas- Lab Overview
12) Expand Connectors, search for Teams, and select Microsoft Teams.
14) You should now have Challenges and Microsoft Teams in your app.
11
Advanced Canvas- Lab Overview
18) Select the Insert tab, click Input and select Drop Down.
21) Set the Items property to the snippet below. If you have difficulty with copy/paste then
type the snippet manually. This snippet will list the available teams in the dropbox
MicrosoftTeams.GetAllTeams().value
13
Advanced Canvas- Lab Overview
23) Scroll down to the Data section and select displayName for Value.
24) Click Input and select Dropdown again. This dropdown will be for the channels in the
team.
25) Rename the dropdown channelsDropdown.
26) Set the Items property to the snippet below. This snippet will show the channels of the
selected team in the second dropdown.
If(!IsBlank(teamsDropdown.Selected),MicrosoftTeams.GetChannelsForGroup(teamsDro
pdown.Selected.id).value)
30) Select the Insert tab, click Text and select Rich Text Editor.
33) Select the messageText control and set the Default value to the snippet below. This
snippet will build the chat message.
Concatenate("New Challenge available <strong>",
[@ModelDrivenFormIntegration].Item.sample_name , "</strong>. Go create your new
ideas.")
15
Advanced Canvas- Lab Overview
35) Set OnSelect to the snippet below. This snippet will post the message to the selected
channel.
MicrosoftTeams.PostMessageToChannel(teamsDropdown.Selected.id,channelsDropdown.
Selected.id,{body:{content: messageText.HtmlText,contentType:1}})
37) Move your Send button and place it below the text box. Resize it to be the same width as
the textbox.
38) Your Canvas application will now look like the inage below.
17
Advanced Canvas- Lab Overview
49) Select Solutions and click Publish All Customizations the solution
4) Select Challenges.
6) The Canvas app should load – use the drop downs to explore teams. Notice the text editor
has pre-filled with information form the loaded Challenge record. Note: your teams
showing may be different than the pictures.
12) Go back to Teams. A new chat should get started in the team and channel you selected.
19