Use a QVar parameter to choose document templates dynamically. A document query finds the templates, and two Other Parameters on your document solution pass the query result to the button. When users click the button, they see only the templates that match the query.

For how QVars work, see Use QVars in Docs Made Easy.

Create the document query

  1. Open Docs Made Easy in Salesforce, click Document Queries, and then click New. The new document query form opens.

  2. In Query Name, enter a name for the query. From the From list, select the object to query, for example Account.

  3. In the SOQL Query section, write the query.

    SOQL Query section with the query that selects templates

  4. Scroll down and click Save. The query appears in the Document Queries list.

  5. Click the document query to open it, and copy the Document Query ID.

    Document Query ID field on the document query record

Add the QVar parameters to the solution

  1. Go to Document Solutions, open the document solution you need, and click Edit in Wizard. The wizard opens.

  2. Click Assign Behaviors, click Other Parameter in the Behavior Settings sidebar, and then click Add Other Parameter. A row with Parameter Name and Parameter Value fields appears.

  3. Enter the first parameter:

    • Parameter Name: documenttemplateid
    • Parameter Value: {qvar0}
  4. Click Add Row, the blue link under the first row. A new blank row with Parameter Name and Parameter Value fields appears.

  5. Enter the second parameter, then click Save:

    • Parameter Name: qvar0Id
    • Parameter Value: the Document Query ID you copied

    Parameter row with qvar0Id set to the Document Query ID, and the Save button

Test the button

  1. Go to a record of the object the solution is built on and click the solution's button.

  2. Check the Document Template File section. It lists all document templates that match the query.

    Document Template File section listing the templates returned by the query

Related: Use QVars in Docs Made Easy · Use SOQL queries in Docs Made Easy