The Create Document button provides access to the DocumentsCorePack dialog from the CommandBar. The button is available on all entities by default after installing DocumentsCorePack. However, there could be scenarios where you need to add this button manually.
Examples:
- Localize: You want to rename the button (e.g. a translated version)
- Missing: The button is missing or was not added during the installation
- Execute OCA: You want to execute a One-Click-Action directly from the CommandBar instead of opening the generic dialog.
- Generate documents for related records: Call the DocumentsCorePack-Dialog for related records.
This article explains how to add the button via the Power Apps Maker portal.
Please note: The following step-by-step description applies to Dynamics 365 & Model-driven apps Online only. For On-Premise deployments, you will have to use the RibbonWorkBench.
Step-by-Step description
Step 1: In ❶ Power Apps navigate on the left bar to ❷ Apps. In this example, the button should appear in the ❸ Sales Hub app (Make sure it is the environment you are working with). Hit the three little dots and select the ❹ Edit function.
Step 2: This site opens. On the left sidebar, all entities are shown. Now select the entity, you want to edit. In this example, it is ❶ Account. More commands are shown when you hit the three dots. Select ❷ Edit command bar and decide whether you want to ❸ Edit it here or Edit in new tab.
Step 3: The Edit command bar for Accounts opens. On this page you can decide if you want to edit in the Main grid, the Main form, a Subgrid view, or an Associated view.
In this article we will cover the two most common options:
How to create the button in the Main Form
Press Edit to continue.
To create a new button, hit the New button and select ❶ Command.
The Command Bar opens. Fill out the following fields:
❶ Label: name it as you like.
❷ Icon: optional
❸ Action: Run Javascript
❹ Library: ptm_globalambutton.min.js
❺ Function name: ptm_openLookupDlg

.
How to create the button in the Main Grid
This overview is displayed. To create a new button, hit the New button and select ❶ Command.
On the right side, a command bar opens. Fill out the following fields:
❶ Label: name it as you like.
❷ Icon: optional
❸ Action: Run Javascript
❹ Library: ptm_globalambutton.min.js
❺ Function name: ptm_openLookupDlg
❻ Parameter 1: SelectedControl
❼ Parameter 2: SelectedControlSelectedItemIds
❽ Parameter 3: SelectedEntityTypeCode
❾ Parameter 4: SelectedControlSelectedItemCount
❿ Parameter 5: SelectedEntityTypeName

❶ Visibility:
- Show: The button is shown permanently.
- Show on condition from formula: ❷ So that the Create Document button is only displayed when one or more records are selected, you need the following command: ❸
CountRows(Self.Selected.AllItems) > 0
If you select the ❹ Hide option at the bottom of the command bar, the command is hidden in-app and designer experiences. This overrides the visibility attributes.
Completing the development of the button on both the Main Grid and the Main Form
Please note: If you want to have a button that you only want to show when a certain field in your app’s data source contains a specific value, you can set the visibility of the button. If you want to learn more read this article.
Don´t forget to Save and Publish your newly created button.
Return to your Dynamics 365. Refresh the page and check, if you can see your newly created button in your entity like in Figure 9.
.
Execute One-Click-Actions from the CommandBar
As of DocumentsCorePack Server version 2020.142, it is now possible to create a custom button via Power Apps to execute a single One-Click-Action (or OCA). This can be useful in situations where an OCA is used often, as it can be used to speed up the process of executing it.
Note: This feature requires the AutoMergeGlobalButton to be updated to version 2020.232 (How to check my version?)
To create this button, it can be set up similar to creating a custom Create Document button, as seen here.
However, the steps to create an OCA button slightly differs depending on if you are creating the custom button for a Main Form or a Main Grid
Main Form
To create a custom button in the Main Form to trigger a single OCA, eleven parameters must be created, with the first ten parameters being set to FirstSelectedItemId.
The eleventh parameter should be a string parameter. The string value should be the ID of the OCA you want to use (Note: OCAs are stored as records of the MSCRM-ADDONS.com OneClickActions table in your Dataverse). Once this is setup, you can save and return to your respective form.
You should now see this button in your command bar.
Main Grid
To create a custom button in the Main Grid, the creation of the button is similar, but the parameters must be set up differently than for the Main Form. The parameters for the Main Grid button should be set up like it shows below.
That´s it! We appreciate your feedback. Please share your thoughts by sending an email to support@mscrm-addons.com.