26. January 2015 10:33

How to add the [Export to Word]-flyout button?

Filed Under(CRM 2013 | CRM 2015 | DocumentsCorePack Server Based 2013 | DocumentsCorePack ServerBased 2015) By Jin

This article outlines how to add the DocumentsCorePack [Export to Word]-button manually.

Requirements: DocumentsCorePack (DCP) for MS CRM 2013/2015

Please note: The button created in this example will be visible on the Account-form for web-clients only.

How to add the [Call Number]-button manually?


First, create a new CRM solution (CRM > Settings > Solutions > New). Then, add the entity to which the DCP-button should be added. This can be done by opening the Add Existing-drop-down menu > Entity. (here: Account)


Figure 1: Create new solution and add entity

In the now appearing dialog, select No, do not include required components.

This is what the result looks like:

Figure 2: Result

At this point, we recommend to do an unmanaged export of this solution (simply to have a backup). 

Once finished, add the following components to the solution (Add Existing > web Resource):

· Web Resource: ptm_dcp_icon_exportword16x16 
· Web Resource: ptm_dcp_js_jslibrary 
· Web Resource: ptm_dcp_js_templatebutton

Please note: the Web Resource names above displayed are Name-fields. 

Figure 3: Components added to Web Resource

Next, open the RibbonWorkBench and select this solution.

Once loaded, drag and drop a Split Button from the Toolbox to your Form-ribbon.

Figure 4: Drag and drop the Split Button

With a right-click on the Split Button a flyout opens. Make another right-click on the flyout-element Delete.

Figure 5: Split Button flyout menu

Next, define its properties on the right side. Please find a sample below. 

· Id: any unique id (here: new.account.Button.form.ptm_dcpExportToWordFlyOutCustom)
· Image16by16: select the included :ptm_dcp_icon_exportword16x16-webresource
· Sequence: position of your button (here: 100)
· Label Text: Any text (here: Export to Word)
· ToolTipDescriptionText: any text (here: Starts the document generation of DCP Client)
· ToolTipTitleText: any text (here: Export to Word)
· All other properties can be left as they are

Figure 6: Split Button Properties

Next right-click on Commands Add New.

Then select the new command.

Figure 7: Enter new command

Define its properties on the right side.

Id: any unique id (here: new.account.command.form.ptm_dcpExportToWordFlyOutBase)

Figure 8: CommandDefinition properties

After that, hit the lookup-icon of Actions and in the popping up dialog click on the [Add]-button.

In the next dialog, select Javascript Function Action and click on the [OK]-button.

Figure 9: Add Javascript Function Action

Define the properties of the next dialog like this:

· FunctionName: DCP.Lib_Registry.printInWord 
· Library: select ptm_dcp_js_jslibrary 
· Parameters: can be left empty

Figure 10: Define properties 

Click on the [OK]-button to in order to complete the process.

Next, click on the lookup-icon of DisplayRules and the following window will open. Click on the [+Add New]-button.

Figure 11: Display Rules-window

Define a unique ID (here: new.account.displayrule.form.ptm_dcpExportToWordFlyOut) and click on the [Add Step]-button. 

Figure 12: Add new display rule

Select Client Type Rule and continue with a click on the [OK]-button.

Figure 13: Select rule type

In the next dialog specify the following fields:

· Default: False 
· InvertResult: False 
· Type: Web

Figure 14: Specify fields 

Finish it with a click on the [OK]-button and then again, click on the [OK]-button.

Now the functionality for the main button is ready.

The next step is to include a command for the population of the flyout-menu. To do so, right-click on Commands > Add New

Enter an Id (here: new.account.command.form.ptm_dcpExportToWordFlyOutPopulate)

And hit the lookup-icon(next to Actions) 

Figure 15: Define the command properties 

Now add the following Javascript Function Action:

· FunctionName: ptmDcpTemplateButton.DynamicMenuDCPTemplate 
· Library: select ptm_dcp_js_templatebutton

Figure 16: Add Javascript Function Action

Next, click on Parameters, click on the [Add]-button and add the following types:

· Type: CrmParameter Name: <empty> Value: CommandProperties
· Type: CrmParameter Name: <empty> Value: SelectedEntityTypeName
· Type: StringParameter Name: <empty> Value: new.account.command.form.ptm_dcpExportToWordFlyOutItem
· Type: CrmParameter Name: <empty> Value: SelectedEntityTypeCode
· Type: BoolParameter Name: <empty> Value: true

Finish the process with a click on the [OK]-button and click again on the [OK]-button.

Figure 17: Add types

The next step is creating the final command. It will be executed when a user hits on a flyout-item.

Right-click on Command > Add New

Figure 18: Add final command

Insert the ID new.account.command.form.ptm_dcpExportToWordFlyOutItem and hit on the Actions lookup-icon.

Figure 19: CommandDefininition Properties

In the now popping-up dialog, click on the [Add]-button. Select Javascript Function Action and click on the [OK]-button.

Define the Javascript function properties as follows:

· FunctionName: ptmDcpTemplateButton.OnClickMenuItem

· Library: select ptm_dcp_js_templatebutton

Figure 20: Javascript Command Properties

Next, click on Parameters and click on the [Add]-button. Insert the following types:

· Type: CrmParameter Name: <empty> Value: CommandProperties

· Type: CrmParameter Name: <empty> Value: SelectedEntityTypeName

· Type: CrmParameter Name: <empty> Value: SelectedControlSelectedItemIds

· Type: CrmParameter Name: <empty> Value: PrimaryEntityTypeName

· Type: CrmParameter Name: <empty> Value: SelectedEntityTypeCode

Figure 21: Define Parameters

Complete with a click on the [OK]-button and then again, click on the [OK]-button.

Back in the main-window of RibbonWorkBench, select the button in the ribbon and choose the recently created commands in the dropdown-boxes Command and PopulateQueryCommand

Figure 22: Select the [Export to Word]-button

To complete the button, click on the [Publish]-button.

Figure 23: Publish the button

When you now open a contact record, you will find the [Export To Word]-button.

The main button and the flyout should work.

Figure 25: Published [Export To Word]-button

The result Xml of the RibbonWorkBench should look like this:


Figure 26: Ribbon Work Bench XML


Figure 27: Ribbon Work Bench XML

You could try to use this Xml for other entities as well.

For example, you could replace .account. with .lead. and change the location of the CustomAction

BUT we cannot guarantee that this is working!!!

That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com.

Tag Cloud

This will be shown to users with no Flash or Javascript.

Page List