Exercise - Customize the command bar

Completed

In this exercise, you add a command bar button to the help request table form. This button is visible for active help requests. When it's clicked, a new task is created for the help request.

Important

Use a test environment with Microsoft Dataverse provisioned and the sample apps enabled. If you don't have one you can sign up for the community plan here.

Task - Prepare your environment

In this task, you create a solution, create a new help request table, and then create a model driven application. If you would prefer to skip this task and use a starting solution, proceed to the Import a solution task.

  1. Navigate to Power Apps maker portal and make sure you are in the correct environment that has the sample apps enabled.

    Screenshot showing environment name.

  2. Select Solutions.

  3. Select + New solution.

  4. Enter Command Bar for Display name, select CDS default publisher for Publisher, and select Create.

    Screenshot showing new solution properties.

  5. Open the Command Bar solution you created.

  6. Select + New and the select Table > Table (advanced properties).

  7. Enter Help Request for Display name, Help Requests for Plural name will auto-populate, and expand Advanced options.

    Screenshot showing the create new table dialog.

  8. Scroll down to the Make this table an option when section, check the Create a new activity checkbox, and select Save.

    Screenshot showing the enable table for activity checkbox.

  9. Expand the Help Request table you created and select Columns.

    Screenshot showing the table columns button.

  10. Open the Status Reason column.

    Screenshot showing the status reason column.

  11. Select New choice.

    Screenshot showing the add new choice button.

  12. Enter Resolved for Label and select Save.

    Screenshot showing a new choice added to the status reason choices.

  13. Select Forms and open the Main form.

    Screenshot showing table forms.

  14. Drag the Status Reason column and drop it in the form header.

    Screenshot showing the status reason reason column getting added to the form header.

  15. Select Save and publish and wait for the form to be published.

  16. Select the Back button.

  17. Select Apps.

  18. Select + New and then select App and then Model-driven app.

    Screenshot showing the create new model-driven application button.

  19. Enter Help Request App for Name and select Create.

  20. Select the Navigation ... button and then select New group.

    Screenshot showing the navigation group.

  21. Go to the properties pane.

  22. Change the Title to Requests and ID to help_requests_group.

    Screenshot showing the navigation group properties.

  23. Next, from the pane on the left side of the canvas under Navigation select Requests ... and then select New page.

  24. Select Dataverse table for Content type and then select Next.

  25. Select Help Request for table and then select Add.

    Screenshot showing the navigation subarea properties.

  26. Select the Help Requests view you just added and then go to the Settings tab in the pane to the right of the canvas.

  27. Change the ID to help_requests_subarea.

    Screenshot showing the help request ID value.

  28. Select Save and wait for the application to be saved.

  29. Select Publish and wait for the application to be published.

  30. Select the Back button.

    Screenshot showing the back button.

  31. Select Publish all customizations, and wait for the publishing to complete.

Task - Import solution

In this task, you import the starting solution into your environment. You only need to complete this task if you didn't complete the Prepare your environment task, above. If you completed the Prepare your environment task, proceed to the Add command button task.

  1. Download the CommandBar_1_0_0_1.zip solution file located in the GitHub and save locally on your computer.

  2. Navigate to Power Apps maker portal and make sure you are in the correct environment that has the sample apps enabled.

  3. Select Solutions.

  4. Select Import solution.

  5. Select Browse.

  6. Choose the file you downloaded and select Open.

  7. Select Next.

  8. Select Import and wait for the solution import to complete.

    Screenshot showing the import solution dialog.

  9. You should see a notification when the import completes. Select Publish all customizations and wait for the publishing to complete.

Task - Add command button

In this task, you add a new command button to the Help Request table main form.

  1. Open the Command Bar solution you created/imported.

  2. Select Apps, and open the Help Request App.

    Screenshot showing the help request application.

  3. Select the ellipsis ... button of the Help Request view and select Edit command bar > Edit.

    Screenshot showing the edit command bar button.

  4. Select Main form and then select Edit.

  5. Select New and then select Command.

    Screenshot showing the add new command button.

  6. Select Power Fx and then select Continue. You need to wait for the Create a component library to finish and the pop up to disappear.

  7. With your NewCommand selected in the canvas, enter Follow Up for the Label, select Use Icon, select Placeholder, and select Show on condition from formula for Visibility.

    Screenshot showing the command properties.

  8. Enter Follow Up for Tooltip title, Tooltip description, and Accessibility text.

  9. Go to the formula bar, select Visible, and paste this formula. This Power Fx formula shows the button if the help request is active, and hide it if it's resolved.

    If(Self.Selected.Item.'Status Reason' =  'Status Reason (Help Requests)'.Active, true, false)

    Screenshot showing the command button visibility formula.

  10. Select Save and publish.

  11. Wait for the publishing to complete.

  12. Select Play.

    Screenshot showing the play button.

  13. Select + New.

  14. Enter Test for Visibility as Name and select Save.

    Screenshot showing the new help request record.

  15. The Follow Up command button should become visible. Change the Status Reason to Resolved.

    Screenshot showing the status reason value.

  16. Select Save.

  17. The Follow Up command button should no longer be visible.

    Screenshot showing the command bar without the follow up button.

  18. Change the Status Reason to Active.

  19. Select Save.

  20. The Follow Up command button should become visible again.

  21. Close the application browser window or tab.

  22. You should now be back to the command bar editor. Don't navigate away from this page.

Task - Add button action

In this task, you add a Power Fx formula that creates a new task that is due in one week when the command button is clicked.

  1. Select Open component library.

    Screenshot showing the open component library button.

  2. Select the Data tab, select Add data, search for tasks, and select the Tasks table.

    Screenshot showing the add data dialog.

  3. Select Save.

  4. Select Publish

  5. Select Publish this version.

  6. Close the component library browser window or tab.

  7. Select Resume.

    Screenshot showing the resume editing the command bar popup.

  8. Select the Follow Up command button you added.

  9. Go to the formula bar and select OnSelect.

    Screenshot showing the on-select action of the follow up button.

  10. Paste this formula in the formula bar. This formula creates a task for the current help request and set the due date to one week from the time the button is clicked and display a notification.

    Patch(Tasks, {Subject: Self.Selected.Item.Name, Regarding: Self.Selected.Item, 'Due Date': DateAdd(Now(),7) }); Notify("Created new task")

    Screenshot showing the on-select command formula.

  11. Select Save and publish.

  12. Wait for the changes to be published.

  13. Select Play.

  14. Open the Test for Visibility help request record.

  15. Select the Follow Up button.

    Screenshot showing the follow up command button.

  16. You should see the notification. Select the Related chevron button and then select Activities,

    Screenshot showing the related activities button.

  17. You should see the created task. Make sure the Due Date is set to 7 days from current date.

    Screenshot showing the created task record.