Skip to main content
Skip table of contents

Custom Buttons

This article shows how to create a basic Dynamo button and add it to an object's layout.

The button will open the document generated for that record, or open a list of available templates and let end users select which one to run.

The button will be added to the Main Object page layout, and end-users with the appropriate profile for that page layout will see the button when they open a record of that object.  

A sample button:

image-20240109-114510.png

Create a Dynamo Template button

Dynamo provides ready-made custom buttons for the following standard Salesforce objects: Account, Contact, and Opportunity. Skip this step if you are working on one of those objects.

In Salesforce Lightning UI: 

  • Go to Setup -> Object Manager -> select the [Object Name]. Click Buttons, Links and Actions.

Click New Button or Link.

Label the button Dynamo Templates. The Name field is filled automatically. You can leave it as it is.

The label can take any name that suits its use. Below are a few examples:

Process: Quote generation and sending → Label: Send Quote

Process: Contract generation → Label: Generate Quote

Process: Order confirmation generation → Label: Generate Order Confirmation

Under Display Type, select Detail Page Button.

From the Behavior list, we recommend that you select: Display in existing window without sidebar.

Paste one of the following URLs into the custom button editor, and replace Object with the API name of the object whose button you are customizing

CODE
/apex/dynamo__DynamoFrame?id={!Object.Id}

For example, if you are creating the button for Contract object to list all templates, the URL will be:

CODE
/apex/dynamo__DynamoFrame?id={!Contract.Id}

If the org is a sandbox org then add also sfEnvironment parameter with value sandbox.

CODE
/apex/dynamo__DynamoFrame?id={!Contract.Id}&sfEnvironment=sandbox

Click Save.

Add the button in Salesforce Lightning UI

In Setup, go to the Object Manager, search, and select the Object you want to use Dynamo in

In the selected object, go to Page Layouts, choose the Page Layout that will need the button

In the Page Layout, select Buttons, drag the button "Dynamo Templates" to the layout in the Custom Buttons area

Select Mobile & Lightning Actions and drag the Dynamo Templates button from there to the Mobile and Lightning Experience Actions area

Click Save

The button will appear in the Object Layout.

How will end users use the button?

When end users open a record in Salesforce, they will see the Dynamo Template button in the layout.

In Salesforce Lightning, the button can be found when users click on the arrow to "Show more actions for this record"


How to filter the template list

Once you follow the instructions to create a Dynamo Button for an object, you allow end-users to open a list of all available Dynamo template files in the organization when clicking the button. This article will show different options to filter that template list view. The configuration is done in Salesforce, by editing template file details, the URL in the VisualForce Page, and in the custom button.

This article shows step-by-step instructions to filter the template list:

  1. Create a new Visualforce Page

  2. Edit the URL in the new Visualforce Page according to your use case

  3. Edit the URL in Dynamo Template button

  4. Edit the template's File Details

1. Create a new Visualforce Page

By default, you can use the DynamoFrame page in the URL for the Dynamo Template button. To customize the button for filtering or other functions, you can create a new Visualforce Page and include more parameters into the page.

In Setup, go to Visualforce Pages

Click New

image-20240108-075202.png

Give a name for the new page. For example, the page is named as Dynamo_Opportunity to tell that this page has specific content for the Dynamo button in Opportunity object.

image-20240109-103850.png

Copy the following code to the Visualforce Markup. (The code used here is the same with the DynamoFrame page, for basic function of the button)

CODE
<apex:page applyBodyTag="false"><apex:stylesheet value="https://dynamo.documill.com/visualforce/dynamo-vf.css" /><apex:includeScript value="https://dynamo.documill.com/visualforce/dynamo-vf.js" /><head></head><body><div class="dynamo-container"><div class="dynamo-loading"></div><apex:iframe width="100%" height="100%" src="https://dynamo-eu1.documill.com/service/sfdco?useFlow=true&customListenerURL=*&serverURL={!$Api.Partner_Server_URL_330}&id={!$CurrentPage.parameters.id}&templateID={!$CurrentPage.parameters.templateID}"></apex:iframe></div><script>initDynamoVisualforce("/{!$CurrentPage.parameters.id}");</script></body></apex:page>

2. Edit the URL in the new Visualforce Page according to your use case

In the new Visualforce page, edit the URL in src="https://..." part according to the use case explained below

 

2.1. Filter the template list by main object

At the end of the http:// URL, add the following parameter, and replace Object with the API name of that object:

CODE
&staticFilters=dynamo__DynamoMainObject__c:Object

The new parameter need to be add before the double quotation " mark

For example: the Visualforce page to filter template list in Opportunity object will have the extra parameter

image-20240109-105118.png

2.2. Allow end-users to filter the template list dynamically

If dynamic filters are used, when end-users click on the Dynamo Template button, the list will be shown like this:

image-20240109-105136.png

Dynamo uses Fields in Content Version as filter criteria. You can use the Salesforce standard fields. or create more custom fields if needed.

  • To create custom fields on Content Version: in Setup, under App Setup -> Customize -> Salesforce Files, click Fields. Click New, and create as many custom fields as you need.

Include the filters parameter in each custom button that should have dynamic filters, and determine the fields you want to filter by. If you want to have several fields to filter by, separate the field names with a comma. With this example parameter you would get filters for Content Version's standard field Language and a custom field Country:

CODE
&filters=Language,Country__c

The full content of the URL for the Visualforce Page would look like this:

CODE
https://dynamo-eu1.documill.com/service/sfdco?useFlow=true&customListenerURL=*&serverURL={!$Api.Partner_Server_URL_330}&id={!$CurrentPage.parameters.id}&templateID={!$CurrentPage.parameters.templateID}&filters=Language,Country__c

2.3. Combine multiple filtering options

You can add many parameters to the custom URL as your business requires.

Example: Filter the list by Main Object and add dynamic filters

If you want the button to list only templates related to Opportunity object, then end-users have a chance to filter that list to show Opportunity-related templates for a specific Country, the custom URL for the button would be like this:

CODE
https://dynamo-eu1.documill.com/service/sfdco?useFlow=true&customListenerURL=*&serverURL={!$Api.Partner_Server_URL_330}&id={!$CurrentPage.parameters.id}&templateID={!$CurrentPage.parameters.templateID}&staticFilters=DynamoMainObject__c:Opportunity&filters=Language,Country__c

To learn more about the contentType, staticFilters, filters and other parameters, check the Parameters for Dynamo Button

3. Edit the URL in the Dynamo Template button

Go to the desired Object in Setup -> Buttons, Links, and Actions, and select the Dynamo Template button you want to edit

Select Edit

In the Custom Button or Link Editor box, link the URL to the new Visualforce page

CODE
/apex/Dynamo_Opportunity?id={!Opportunity.Id}

For example:

image-20240109-105159.png

Click Save

If you cannot edit the button URL, mostly in the case of ready-made buttons in the Accounts, Opportunities, and Contacts object, you can create a new button following the instructions How to create a Dynamo Button for an object

4. Edit the template's File Details

We have created a Dynamo Template record type and a DynamoMainObject custom field to help you categorize the template file in Salesforce. To filter the template list by main object, you need to set the value for the DynamoMainObject field.

Go to Files in Salesforce. select the Dynamo template file

  • In Classic UI, select Go to Content Detail Page

  • In Lightning UI, select Edit File Details

In the DynamoMainObject field, type in the Main Object's API name. In the example, when end-users click on the Dynamo Template button, the list will show only templates using Opportunity as the main object.

image-20240109-105227.png

Similarly, you can add value to Language or other custom fields to be used in filtering the template list

Click Save

Parameters for Salesforce Custom Buttons and Links

The structure of the URL for custom buttons and links includes 4 main parts:

  1. Server URL: Each Dynamo button will start with the Dynamo service URL. When the button is clicked, end-users will be directed to the Dynamo server to start the process. Parameters are specified after the service URL.

  2. Parameters for the server: These parameters are required by Dynamo's server and must be included in all Dynamo buttons.

  3. ID parameter: The parameter specifies the Salesforce record to be used as the Main Record.

  4. Parameters for the page: These parameters affect the Dynamo page that the button will open. They are not compulsory. Depending on the use cases and needs, different parameters will be used.

Example of custom URL

Below is an example URL for a custom button in the Opportunity object, with a line break after each type of parameter.

Service URL

https://dynamo-eu1.documill.com/service/sfdco?

Parameters for the server

sessionID={!$Api.Session_ID}&serverURL={!$Api.Partner_Server_URL_330}

ID Parameter

&id={!Opportunity.Id}

Parameters for the page

&useFlow=true&endURL=https://eu4.salesforce.com/{!Opportunity.Id}&templateID=069570000051ZAU

The custom URL specifies that when the button is clicked, a page will be opened directly in a template file and the data from the corresponding Opportunity record will be used to create the document.

  1. Server URL

Dynamo has 2 server URLs. One is used for the Document Controller (Legacy) templates, which is discontinued and only in supporting mode for existing templates.

In Salesforce Classic UI, you can use the Visual Force page or just point the button to the Dynamo server URL

In Salesforce Lightning Experience, a Visualforce page is needed. Dynamo server URL will be written on that page and the custom buttons needed to be pointed at the page instead of server URL. 

Dynamo provides a sample Visual Force page under the name DynamoFrame.

Server Name

Server URL

Dynamo Service

CODE
https://dynamo-eu1.documill.com/service/sfdco

Visualforce Page for Lightning Experience

CODE
/apex/dynamo__DynamoFrame

*dynamo__DynamoFrame is the Visualforce Page that contain the custom URL you want to use for the button, created as default by Dynamo. If you have another customized Visualforce Page, please indicate the page name there.

  1. Parameters for the server

Parameter definitions follow the notation parameterName=value. The first parameter is preceded with a question mark ?, and parameters are separated from each other with an ampersand symbol &.

Dynamo receives parameters in a variable named param. Templates can refer to parameter values with the syntax ${param.parameterName}, for example ${param.id}.

The parameters listed in the following table must be included in all Dynamo buttons, because the Dynamo server requires them. Use the names and values as they are specified.

Parameter Name

Value

Description

serverURL

{!$Api.Partner_Server_URL_330}

Salesforce URL for API calls. The API version number is not relevant as Dynamo replaces it. Versions 330, 370 and 380, for example, can be used here without issues.

sessionID

{!$Api.Session_ID}

ID of the Salesforce user session.

useFlow

true

This parameter is required only if you have flow based templates.

Example:

In practice, this means that the URL of each Dynamo button will begin more or less like this:

CODE
https://dynamo-eu1.documill.com/service/sfdco?sessionId={!$Api.Session_ID}&serverURL={!$Api.Partner_Server_URL_330}
  1. ID Parameter

The ID parameter specifies the main record — that is, the record to which the composed document is related. It is usually defined in all buttons that start the document composition process or open a list of existing documents.

Parameter Name

Value

Descriptions

id

{!Object.Id}

The API name of the main record, that is, the record to which the composed document is related.

Example: Define the ID parameter in the Custom Button editor

Separate the parameter from other parameters with an ampersand, and then type in id and an equation mark:  &id=

CODE
https://dynamo-eu1.documill.com/service/sfdco?sessionId={!$Api.Session_ID}&serverURL={!$Api.Partner_Server_URL_330}&id=

Choose the main object from the Select Field Type drop-down list and select ID from the Insert Field drop-down list.

image-20240109-105736.png

The result should look something like this:

CODE
https://dynamo-eu1.documill.com/service/sfdco?sessionId={!$Api.Session_ID&serverURL={!$Api.Partner_Server_URL_330}&id={!Account.Id}

Example: Define the ID parameter when there is no main record

In some cases, such as creating reports or using data from queries, the templates will not have any main object or main record. The ID parameter in the button URL will have an value.

The URL will look like this:

CODE
https://dynamo-eu1.documill.com/service/sfdco?sessionID={!$Api.Session_ID}&serverURL={!$Api.Partner_Server_URL_330}&id=x

Additional custom parameters:

You can define additional custom parameters in the same way as the record ID — just replace 'id' with another name. Parameter names can include letters (a–z and A–Z) and numbers (0–9) but do not start a name with a number. Do not use spaces, other special characters, or Java’s keywords in parameter names.

  1. Parameters for the page

The parameters listed in the following table will affect the page that the button opens. Use the names specified here — otherwise, the server will not be able to recognize the parameter.

Parameter Name

Value Type

Description

Example

autoClose

Boolean

If the value of this parameter is true, the page closes after the user has opened the composed document.NOTE: Not supported when useFlow=true.

&autoClose  

autoOpenSingle

Boolean

If the value of this parameter is true and the template list contains only one template, that template is run automatically. If not defined, this parameter's value defaults to the value of the docs or feedparameter, whichever is used in the URL.NOTE: Not supported when useFlow=true.

&autoOpenSingle=true 

endURL

URL

When the flow ends (no more screens or steps), the user is navigated back to this URL.NOTE: Only usable when useFlow=true. Also note that this value might have to URL-encoded to work properly.

&endURL=https://eu1.salesforce.com/{!Opportunity.Id}

contentType

Salesforce content type

Specifies the content type (INVALID) of files that are listed on the page that the button opens. All content documents that match the content type are listed, whether they are Dynamo templates or not. Separate multiple values with a comma. If this parameter is omitted and no other filters are set, all Dynamo templates that have been saved with the Dynamo Office add-in and that are available to the user, are listed.

&contentType=My Own Content Type

docs

Boolean

Specifies whether the button opens a list of templates or a list of documents that are linked to the main object through a content type. If this parameter is not included or if its value is false, templates are listed; if the value is true, linked documents are listed. This parameter is typically used with an Update Documents button.

&docs=true

feed

Boolean

If this parameter is included with the value of true, only documents that are stored as feed attachments of the record are listed. This parameter is typically used with an Update Documents button.

&feed=true

fields

Content field(s)

Specifies the columns that are presented in the template list. Separate multiple values with a comma. If the parameter is omitted, the Title field is shown. See the example below for accessing available content fields.

&fields=Title,Description,LastModifiedDate

filters

Content field(s)

Defines filters whose values the user may alter to change which templates are listed. Separate multiple values with a comma. See the example below for accessing available content fields.

&filters=Language,Country__c

folderId

Content Library

Specifies the content library whose templates will be listed. All content documents that can be found from the content library are listed, whether they are Dynamo templates or not.

&folderId=058D0000000xxxx

orderBy

Order of the templates

Added to the SOQL query that lists the templates, but only when PathOnClient or Content type based template listing is used.

&orderBy=Title

staticFilters

Content fields(s)

Defines fixed filters with the syntax fieldName:value. The template list will only show documents where the specified field has the specified value. Separate multiple filters with a comma, and multiple values with a dollar sign ($). With multi-select picklist fields, use brackets around the value(s) and an asterisk (*) if several values of the multi-select picklist are accepted. To perform wildcard filtering, start the value with LIKE[ and use an asterisk (*) to allow partial matches. End value with the closing bracket to end the LIKE[]-expression.

&staticFilters=DynamoMainObject__c:Opportunity,Language:en_US&staticFilters=Language:en_US$en_GB$it&staticFilters=multiPicklistField:[value1*value5]&staticFilters=Title:LIKE[*TEST*]

templateID

File ID

Specifies a single template that is run. If this parameter is included, the template list is skipped and the specified template is automatically run. The value should be the template's Content Document ID.

&templateID=069D000000xxxxx

Example: Display the File Name and Last Modified Date in the template list

In the Custom Button editor, add the field parameter &fields=

Choose Content Version from the Select Field Type drop-down list and select a field from the Insert Field drop-down list.

image-20240109-105820.png

Remove !ContentVersion. and the curly brackets {}

image-20240109-105838.png

The result should be something like:

CODE
https://dynamo-eu1.documill.com/service/sfdco?sessionId={!$Api.Session_ID&serverURL={!$Api.Partner_Server_URL_330}&id={!Account.Id}&fields=Title,LastModifiedDate

Repeat the steps to add more value.

Notes:

  1. The four template listing parameters conflict, so only one of them can take effect. If more than one of them has a value that would affect the template listing, their priority is: "docs" > "feed" > "folderID" > "contentType"

  2. If you use Language as value for the fields parameter, make sure that Multilanguage search and contribute is enabled in your organization’s CRM Content settings.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.