Loading
Salesforce Enforces New Security Requirements in Summer 2026Read More
Vlocity Contract Lifecycle Management
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Save Generated Documents to a Default Library

          Save Generated Documents to a Default Library

          Create a trigger to save all generated documents to the Vlocity Document Template Library and provide library access to a user.

          REQUIRED EDITIONS AND USER PERMISSIONS
          Available in: Lightning Experience
          Available with Vlocity Contract Lifecycle Management: Enterprise, Performance, and Unlimited editions.
          USER PERMISSIONS NEEDED  
          To provide users access to the Vlocity Document Template Library.

          ContractMgmtInd HINS Admin User

          OR

          ContractMgmtInd CME Admin User

          1. Create a trigger to save generated documents to the Vlocity Document Template Library.
            Users who have access to the library can view all the generated documents.
            1. In your Salesforce org, from Setup, select Object Manager.
            2. Enter Document Element in the Quick Find box, then select Contract Document Element.
            3. Click Triggers | New.
            4. Paste the sample trigger.
              trigger ContractDocumentCollection on vlocity_cmt__ContractDocumentCollection__c (after Insert) {
                  Set<Id> contentVersionIdsInserted;
                  if (Trigger.isInsert) {
                      contentVersionIdsInserted = new Set<Id> ();
                      for(SObject so: Trigger.new) {
                          vlocity_cmt__ContractDocumentCollection__c docCollection = (vlocity_cmt__ContractDocumentCollection__c)so;
                          if(docCollection.vlocity_cmt__ContentVersionId__c != null) {
                              contentVersionIdsInserted.add(docCollection.vlocity_cmt__ContentVersionId__c);
                          }
                      }
                      Id workspaceId = [ SELECT Id, Name FROM ContentWorkspace WHERE Name = 'Vlocity Document Template Library' LIMIT 1].Id;
                      List<ContentDocumentLink> contentDocumentLinks = new List<ContentDocumentLink>();
                      List<ContentVersion> contentVersions = [SELECT ContentDocumentId FROM ContentVersion where Id IN :contentVersionIdsInserted];
                      for(ContentVersion contentVersion: contentVersions) {
                          ContentDocumentLink documentLink = new ContentDocumentLink(ContentDocumentId=contentVersion.ContentDocumentId, LinkedEntityId=workspaceId, ShareType='I', Visibility='AllUsers');
                          contentDocumentLinks.add(documentLink);
                      }
                      Insert contentDocumentLinks;
                  }
              }
              
            5. Save your changes.
          2. From the App Launcher, find and select Files.
          3. Click Libraries | Vlocity Document Template LibraryManage Members.
          4. For Add Members, select People.
          5. Enter the name of the user in the search field.
          6. For access, select Viewer, Library Administrator, or Author.
          7. Click Add.
           
          Loading
          Salesforce Help | Article