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
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
Create logic to save the edited text
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
In Main tab, at the first step Start, select Edit Step
1.1. Add path to the document
In Filter box on the right pane, search for set
Drag and drop the set tag in Variables library to the workspace in the middle, before the Go to tag
Select the added set tag. In the set attributes on the left pane, add:
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
In the query attributes, give the following values:
var: existingContentDocumentsselect: SELECT ContentDocumentId, ContentDocument.LatestPublishedVersion.Id FROM ContentDocumentLink WHERE LinkedEntityId = '${id}' AND ContentDocument.LatestPublishedVersion.PathOnClient ='${filePath}' LIMIT 1
1.3. Load the previous content document if there is
Under the query tag, add an if tag from Conditionals library
In if attributes, give the test value:
test: ${not empty existingContentDocuments}
Add loadLatestContentVersion tag from SFDC File library as a child tag of if
In loadLatestContentVersion attributes, give the values:
var: documentPDFcontentDocumentId: ${existingContentDocuments.ContentDocumentId}
1.4. Restore edited text from previous version
Add restroreStringSet from Variables library as another child tag of if
In restoreStringSet attributes, give the values:
prefix: edit_readFrom*: ${documentPDF}
2. Create logic to save the edited text
Click Main in the title to go back to the template's logic
Click Edit Step to open logic in "Preview PDF - Start"
Add the storeStringSet tag from Variables library to the workspace in the middle, after the exportPDF tag
In storeStringSet attributes, give the values:
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
In the logic, select the query tag
Change the select value of the query attributes to
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:
doc: ${documentPDF}contentDocumentId: ${existingContentDocuments.ContentDocumentId}title: ${fileName}pathOnClient: ${filePath}linkToId: ${id}
In the 2nd createContentVersion, after the otherwise tag, give the value for the attributes:
doc: ${documentPDF}title: ${fileName}pathOnClient: ${filePath}linkToId: ${id}
Test and save the template