Overview

Out of the box, Docomotion installs a Generate Document button labeled “Generate Documents” for the following Salesforce objects:

  • Account
  • Opportunity
  • Lead
  • Contact
  • Case

You can add this button to the Layout of any Salesforce Object.

However, if you wish to generate documents from your custom Objects, you are required to add a new Generate Document button to each custom Object.

You can also add a custom button that includes a java script. This enables you to dynamically add to the output data based on the user who generated the output.

Salesforce Classic – Adding the Generate Document Button to the Object Layout

In order to generate documents you need to add the new button to the Layout of the Object designated as the Main Object of the Form.

To add the Generate Document button to the Object Layout in Salesforce Classic:

  1. In the Salesforce window, from the dropdown list select Sales and navigate to the Object where you would like to display the button and select a specific Object.
  2. Open the slide menu on the right and select Edit Layout.
  3. In the [Object] Layout page, select the button, and drag and drop the button to Customs Buttons.

Salesforce Lightning – Adding the Generate Document Button to the Object Layout

In order to generate documents you need to add the new button with Action Type: Custom Button (not Action Type: Quick Action) to the Layout of the Object designated as the Main Object of the Form.

To add the Generate Document button to the Object Layout in Salesforce Lightning:

  1. In the Salesforce window, from the dropdown list select Sales and navigate to the Object where you would like to display the button and select a specific Object.
  2. Open the slide menu on the right and select Edit Layout.
  3. In the [Object] Layout page, click Mobile and Lightning Actions, select the button, and drag and drop the button to the Salesforce Mobile and Lightning Actions bar.

Make sure you are using the Generate Documents button with Action Type: Custom Button (not Action Type: Quick Action).

generate documents Lightening

 If you add the wrong button, the user generating the output will receive the following screen and not be able to generate output.

Mobile – Adding the Generate Document Button to the Object Layout

To generate documents from a mobile device you need to add the button also to the Object layout in Salesforce1.
For more information please refer to Adding the Generate Documents Button to Salesforce1 (Mobile App).

To add the Generate Document button to the Object Layout in Salesforce Mobile:

  1. In the Salesforce window, from the dropdown list select Sales and navigate to the Object where you would like to display the button and select a specific Object.
  2. Open the slide menu on the right and select Edit Layout.
  3. In the [Object] Layout page, click Mobile and Lightning Actions, select the button the with Action Type: Quick Action (not Action Type: Custom Button), and drag and drop the button to the Salesforce Mobile and Lightning Actions bar.

Make sure you are using the Generate Documents button with Action Type: Quick Action.
generate documents Salesforce1

Creating a New Generate Document Button

You can create the Generate Document button to add to any Object.
After creating the button you need to configure the size of the window that opens after the user clicks the button.

The recommended size depends on screen resolution. For a screen resolution of 1280X1024, it is 900 X 700.

To create a button for an Object:

1.  In the Salesforce window, from the dropdown list select Docomotion, and click Setup to display the In Salesforce Setup sidebar.
2.  In Salesforce Setup sidebar, in the App Setup area:

  • For Salesforce objects, navigate to: Customize > [Object, i.e. Contacts] > Buttons, Links and Actions.
  • For custom objects navigate to: Create > Objects > [Object, i.e. MyCustomObject] > Buttons, Links and Actions.

3.  Click New Button or Link to display the New Button or Link page.
4.  In the Label text box assign the button a name (Generate Document), this will be displayed on the Page Layout for the Object.
5.  From the Display Type buttons select the Detail Page Button display type.

If you want to work with a Console app, from the Behavior drop-down list select: Display in existing window with sidebar.

6.  From the Content Source dropdown list select URL.
7.  Paste the following text into the text area:

           /apex/doco__VF02_GenerateDocument?id={!Object.Id}

Replace the (!Object.Id) text with the Object API Name you want to use (i.e. ‘Contact.Id’).API NAME

Tip:
To find the API Name of your Object, go to Setup and search “Objects“.
In the Objects page click on your Object, you will then see your Object’s API Name.The URL should look like this:
/apex/doco__VF02_GenerateDocument?id={!ObjectTest__c.Id}

Docomotion4CPQ Package:
When using the Docomotion4CPQ package replace doco__ with doco4cpq__.
Community Users URL:
Note that community users should use the following URL:
../apex/doco__VF02_GenerateDocument?id={!ObjectTest__c.Id}

8.  Click Save.

To configure the Generate Document window size:

1.  In the Salesforce window, from the dropdown list select Docomotion, and click Setup to display the In Salesforce Setup sidebar.

2.  In Salesforce Setup sidebar, in the App Setup area navigate to: Customize > [Object, i.e. Contacts]  > Buttons, Links and Actions.

Adding a Generate Button for Output Incorporating Generator Information

This option is only available in the web application and not in the mobile app (Salesforce1).

If you want to generate output that includes information that is updated according to the user who generates the output, you need to create a new button where the behavior is “Execute JavaScript” and the Content Source is a javascript, and add the button to the output generation page.

This enables you to add data that will be updated according to the javascript.

To add a button that enables including generator information:

  1. Add a new user lookup field to the main record.
  2. Add the required fields, based on the added user lookup, to the Form.
  3. Replace the out-of-the-box generation button with the new javascript button.

JavaScript Example:

The following example is based on Opportunity object. The field to be used in the Form is: GENERATOR__c

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}

var myObj = new sforce.SObject('Opportunity');

myObj.id = "{!Opportunity.Id}";

myObj.GENERATOR__c = "{!User.Id}";

var results = sforce.connection.update([myObj]);

location.reload = true;

window.open('/apex/doco__VF02_GenerateDocument?id={!Opportunity.Id}', '_blank',

'height=750,width=1000,resizable=yes,scrollbars=yes,toolbar=no,menubar=no');