Profile

SnapApp Document Generation

on 06-12-2024 12:00 AM by SnapApp by BlueVector AI

341

SnapApp Document Generation allows you to take a document template in SnapApp, merge it with SnapApp data, and generate a DOCX or PDF file.

Table of Contents

Create your Template File

You can create this in MS Word or Google Docs. Here’s the provided content converted into Markdown:

Document Generation Example — Field Substitution

  1. Current Object You can merge any field from the current object by enclosing it in double brackets.
  2. Id: [[id]]
  3. Field Name: [[name]]

  4. Expressions You can add content from an expression by enclosing it in like.

  5. Application Name: <<CURRENTAPP()>>

  6. Referencing Parents You can pull any field from any ancestor by specifying the ref field that points to the parent then the field name. You can do this recursively and go up as high as you like.

  7. Parent Record Example: [[created_by.email]]
  8. Grand Parent Record Example: [[created_by.created_by.id]]

  9. Referencing Children You can display any field from any child record using the following syntax. The example below will create a bulleted list of related tasks for a record. <<START:tasks>> <<[[subject]]>> <<END>>

  10. Referencing Other Objects You can use the SELECT function to reference other objects. <<START:SELECT('templates','*','id','43a31a89-4efe-4f46-a99f-4d31ae740184',dictionary=True)>> <<[[id]]>> <<[[name]]>> <<[[created_on]]>> <<END>>

  11. Using SELECT Function with Filters To use a SELECT function with a filter with one or more conditions: <<START:SELECT('activities','*',filters=[('type','Email','='),('created_by',[[created_by]],'=')],order_by='id',dictionary=True)>> <<[[subject]]>>: <<[[body]]>> <<END>>

  12. Substitution in the Formula <<START:SELECT('templates','*','id',[[id]],dictionary=True)>> <<[[id]]>> <<[[name]]>> <<[[created_on]]>> <<END>>

  13. Images You can render an image saved on a record using the following syntax:

  14. [[IMAGE:image]]

  15. Conditional Logic You can show and hide sections using IF, ELSE, ENDIF statements enclosed in brackets. Here is an example: <<IF:ISBLANK([[image]])>> This is no image for [[name]] <<ELSE>> This is an image for [[name]]. Here it is: [[IMAGE:image]] <<ENDIF>>

  16. Table With Child Records Sample

    Subject Status Priority Due Date
    <<START:tasks>>
    <<[[subject]]>> <<[[status]]>> <<[[priority]]>> <<[[due_date]]>>
    <<END>>
  17. Table With External Records Example

    ID Name Date
    <<START:SELECT('templates','*','id','43a31a89-4efe-4f46-a99f-4d31ae740184',dictionary=True)>>
    <<[[id]]>> <<[[name]]>> «[[created_on]]>>
    <<END>>

Now using the above rules, the user can replace them with the appropriate object names and their related fields in various parts of the documents and prepare their document. Export as DOCx file

Create the Template Record

  • Navigate to Settings > UX > Templates.
  • Select Document As Source
  • Browse and upload the template file you created.
  • Select Active checkbox → Save

Create a Generated Field

Add a new File type field on the object that will contain the generated document.

Add the Generate Field to View

  • Add the Generated Field from Step 3 to view where you want to view it.
  • This is often the same view where the generator button resides.
  • This will be the file where the generated file will be stored.

Note: This addition of the File type field and adding it to the view is only required if user wants to store the generated document in a field in that object. This Field creation can also be avoided.

Create the Workflow Record

  • Navigate to SettingsAutomationsWorkflows.
  • Click +Add New to create a new workflow
  • After the Create view appears,
  • Set the Type to be API if triggered by a button.
  • Select the Object that will trigger the workflow from the dropdown list. Set the status as active.

Add an Action

  • Create the SettingsAutomationActions.
  • Provide a Name for the action
  • Select the Template ID form the dropdown
  • Choose ‘Document Generation’ as Type
  • Choose the Template that you had previously created in the dropdown.
  • Choose the Generation Location:

    1. Field: Choose this option if you want to generate the document and store it in a field of that object.
    2. Attachments: Choose this option if you want the generated document to be stored under the template object named Attachments
  • Choose the Generated File Field. This is a field on the selected object of type ‘file’ that will be used to store the generated document. (This option will show up only if the user chooses ‘Field’ as the Generation Location)

  • Choose the output type you want (PDF, DOCx)
  • Choose the Worklflow ID from the dropdown list → Save

Add a Custom Button to View

  • Navigate to SettingsUXViews.
  • Open the view where you want to add the button using the View Builder
  • Create a custom button to call the workflow or workflow action.
  • Provide a Button Name. This button name will be displayed in the view.
  • Add an Icon that makes sense to this action
  • Select the URL: User can select Workflow or Action depending on what they have created previously.
  • For Actions: In the Action Field, choose the Action that was previously created
  • For Workflows: In the workflow field, select the Workflow that was previously created from the dropdown
  • Set Target to be Background
  • Toggle the Active checkbox → Save

Verify

Open a record of the object using the view where you added the button - Click the button for generating the document

  • Scenario 1 - Generate as a Field value: Make sure the field you created to generate this field is displayed in the view. If successful, when you click the custom button, the field should appear in the view with the link to the generated document.
  • Scenario 2 - Generate as an Attachment:
  • On clicking the button, if successful, the document will be generated and stored in the related object named Attachments under that record.

Thank you for following these steps to configure your SnapApp components effectively If you have any questions or need further assistance, please don’t hesitate to reach out to our support team. We’re here to help you make the most out of your SnapApp experience.

For support, email us at snapapp@bluevector.ai


Generate Text