Skip to main content
Skip table of contents

How to keep text from previous version (Legacy)

Update from 2018/01 release:

This instruction is for templates created before the 2018/01 release. For those templates created after the 2018/01 release, this function is automatically included when the Editable Content is activated. Template designers can skip these steps.

Restoring users' edited text from previous version and match them to the newly created document is an enhanced function of Documill Dynamo's version control, which allow users to:

  • Continue working on the draft document in their convenient time

  • Retain their customized text when creating a new document with updated Salesforce data

Content includes:

Requirement

  1. Add logic to load previous content document in the beginning of the process

    • Add path to the document

    • Query the previous content document

    • Load the previous content document if there is

    • Restore edited text from previous version

  2. Create logic to save the edited text

  3. Edit logic when saving final PDF document

Requirement

  • The functionality can be achieved only with Advanced Template.

  • The saving option of the template is: Save new document as a new version of the existing file

  • Delete the PDF documents created in the test record before adding the new logic

  • There is at least an editable group or an editable span in the template.

  • Editable Content in Settings is Basic Editing or Advanced Editing

1. Add logic to load previous content document in the beginning of the process

Click the Main module to open the template's logic

image-20240109-100220.png

In Main tab, at the first step Start, select Edit Step

image-20240109-100226.png

1.1. Add path to the document

In Filter box on the right pane, search for set

image-20240109-100233.png

Drag and drop the set tag in Variables library to the workspace in the middle, before the Go to tag

image-20240109-100239.png

Select the added set tag. In the set attributes on the left pane, add:

CODE
var: filePathvalue: dynamo/doc.pdf

1.2. Query the previous content document

Similar, add a query tag from SFDC SOQL library after the set tag

image-20240109-100247.png

In the query attributes, give the following values:

CODE
var: existingContentDocumentsselect: SELECT ContentDocumentId, ContentDocument.LatestPublishedVersion.Id FROM ContentDocumentLink WHERE LinkedEntityId = '${id}' AND ContentDocument.LatestPublishedVersion.PathOnClient ='${filePath}' LIMIT 1
image-20240109-100253.png

1.3. Load the previous content document if there is

Under the query tag, add an if tag from Conditionals library

image-20240109-100259.png

In if attributes, give the test value:

CODE
test: ${not empty existingContentDocuments}
image-20240109-100306.png

Add loadLatestContentVersion tag from SFDC File library as a child tag of if

image-20240109-100311.png

In loadLatestContentVersion attributes, give the values:

CODE
var: documentPDFcontentDocumentId: ${existingContentDocuments.ContentDocumentId}
image-20240109-100317.png

1.4. Restore edited text from previous version

Add restroreStringSet from Variables library as another child tag of if

image-20240109-100322.png

In restoreStringSet attributes, give the values:

CODE
prefix: edit_readFrom*: ${documentPDF}
image-20240109-100328.png

2. Create logic to save the edited text

Click Main in the title to go back to the template's logic

image-20240109-100335.png

Click Edit Step to open logic in "Preview PDF - Start"

image-20240109-100340.png

Add the storeStringSet tag from Variables library to the workspace in the middle, after the exportPDF tag

image-20240109-100347.png

In storeStringSet attributes, give the values:

CODE
prefix: edit_storeTo: ${documentPDF}

3. Edit logic when saving final PDF document

Click Main in the title to go back to the template's logic

  • If you use the Auto Save function, click Edit Step to open the logic of the "Auto-Save" step

  • If you use the Manual Save function, click Edit Step to open the logic of the "Save Options - End" step

image-20240109-100355.png

In the logic, select the query tag

image-20240109-100401.png

Change the select value of the query attributes to

CODE
SELECT ContentDocumentId, ContentDocument.LatestPublishedVersion.Id FROM ContentDocumentLink WHERE LinkedEntityId = '${id}' AND ContentDocument.LatestPublishedVersion.PathOnClient ='${filePath}' LIMIT 1

In the choose tag below the query, edit the value of the 2 createContentVersion tags

In the 1st createContentVersion, after the when tag, give the value for the attributes:

CODE
doc: ${documentPDF}contentDocumentId: ${existingContentDocuments.ContentDocumentId}title: ${fileName}pathOnClient: ${filePath}linkToId: ${id}
image-20240109-100406.png

In the 2nd createContentVersion, after the otherwise tag, give the value for the attributes:

CODE
doc: ${documentPDF}title: ${fileName}pathOnClient: ${filePath}linkToId: ${id}
image-20240109-100412.png

Test and save the template

JavaScript errors detected

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

If this problem persists, please contact our support.