Exercise - Customize the command bar
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.
Navigate to Power Apps maker portal and make sure you are in the correct environment that has the sample apps enabled.

Select Solutions.
Select + New solution.
Enter Command Bar for Display name, select CDS default publisher for Publisher, and select Create.

Open the Command Bar solution you created.
Select + New and the select Table > Table (advanced properties).
Enter Help Request for Display name, Help Requests for Plural name will auto-populate, and expand Advanced options.

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

Expand the Help Request table you created and select Columns.
Open the Status Reason column.

Select New choice.

Enter Resolved for Label and select Save.

Select Forms and open the Main form.
Drag the Status Reason column and drop it in the form header.
Select Save and publish and wait for the form to be published.
Select the Back button.
Select Apps.
Select + New and then select App and then Model-driven app.
Enter Help Request App for Name and select Create.
Select the Navigation ... button and then select New group.
Go to the properties pane.
Change the Title to Requests and ID to help_requests_group.

Next, from the pane on the left side of the canvas under Navigation select Requests ... and then select New page.
Select Dataverse table for Content type and then select Next.
Select Help Request for table and then select Add.
Select the Help Requests view you just added and then go to the Settings tab in the pane to the right of the canvas.
Change the ID to help_requests_subarea.
Select Save and wait for the application to be saved.
Select Publish and wait for the application to be published.
Select the Back button.
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.
Download the CommandBar_1_0_0_1.zip solution file located in the GitHub and save locally on your computer.
Navigate to Power Apps maker portal and make sure you are in the correct environment that has the sample apps enabled.
Select Solutions.
Select Import solution.
Select Browse.
Choose the file you downloaded and select Open.
Select Next.
Select Import and wait for the solution import to complete.

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.
Open the Command Bar solution you created/imported.
Select Apps, and open the Help Request App.
Select the ellipsis ... button of the Help Request view and select Edit command bar > Edit.
Select Main form and then select Edit.
Select New and then select Command.

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.
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.

Enter Follow Up for Tooltip title, Tooltip description, and Accessibility text.
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)Select Save and publish.
Wait for the publishing to complete.
Select Play.

Select + New.
Enter Test for Visibility as Name and select Save.
The Follow Up command button should become visible. Change the Status Reason to Resolved.
Select Save.
The Follow Up command button should no longer be visible.
Change the Status Reason to Active.
Select Save.
The Follow Up command button should become visible again.
Close the application browser window or tab.
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.
Select Open component library.

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

Select Save.
Select Publish
Select Publish this version.
Close the component library browser window or tab.
Select Resume.

Select the Follow Up command button you added.
Go to the formula bar and select OnSelect.
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")Select Save and publish.
Wait for the changes to be published.
Select Play.
Open the Test for Visibility help request record.
Select the Follow Up button.
You should see the notification. Select the Related chevron button and then select Activities,
You should see the created task. Make sure the Due Date is set to 7 days from current date.










