Saving a document in SharePoint online

Last updated 2019-10-09 18:50:56 UTC

The built-in DocumentTRAK web hook for SharePoint onliune is available starting with version 6.33 of AssureSign.

When the DocumentTRAK hook fires, the hook authenticates with your SharePoint credentials and saves the document being passed in the library you specify. This can be configured based on special classic template parameters passed from a Submit of a document through our solution for Dynamics CRM, but this hook may be configured on any other AssureSign template you design.

To configure the hook, from the Administration and Settings page, select DocumentTRAK and continue to Notification Administration.  Select the Document Transmission tab and click the "Add Document Transmission" button.  Select to "Embed in a WebHook" and pick the SharePoint design.


  • a unique name for your webhook.
  • the Username and Password for a user of your SharePoint online instance that has rights to save files in the library you specify.
  • the SharePoint site URL, which may resolve to a specific subsite, for example
  • The specific SharePoint library, which is a relative path that exists in the SharePoint site, for example
    • contracts
    • account/accountA
  • The file name to be saved in SharePoint

The SharePoint URL, library and file name may all be built using merge fields.  Advanced merge field syntax including javascript is also supported.

It is important to note that the web hook will not create libraries in SharePoint.  The library must exist else the hook will fail. In addition, the hook will write out only new PDFs to SharePoint.  If a file with the same name already exists, the hook will fail.

You may also use the advanced merge field syntact in the File Name text you enter.  The following example uses the DocumentName merge field, and adds a unique date element calculated from the Completion Date merge field to ensure the file name will be unique:

[Document Name].signed.[{formatDate(get('Completion Date'), 'YYYY-MM-DD_hh-mm-ss')}].pdf

Add the Notification to Templates

Modify your templates as follows to use your DocumentTRAK notification:

For existing classic templates,

  • select Edit on the Existing template to be modified. Then, Select Edit Workflow. On "Document Transmission", select "New" and pick this design from the "Design Name" list.  Save after making your selection.

For Simple Setup templates,

  • add the hook by editing the template, selecting Notifications from the left side bar, and selecting "Add Document Transmission" on the DocumentTRAK tab.

Using the Hook with Documents Sent from Dynamics 365

If you submitted the document through the Dynamics CRM AssureSign solution, and your configuration allows passing of SharePoint storage location information, then the solution passes additional parameters that are intended to be used for saving the document in SharePoint. These parameters are:

  • AssureSignCRM:SharepointURL
  • AssureSignCRM:Library

Note: You must enable "Store Completed Document in SharePoint" on your AssureSign Configuration in CRM for these extra parameters to be passed. If set to Yes, when the AssureSign Document record form is used to submit, you will be able to select from SharePoint storage locations of entities related to the AssureSign Document record. You may also set these values in workflow processes configured to submit to AssureSign.

If these will always be present on the template you will use this DocumentTRAK design with, then you could use the following in configuring the hook (the brackets must be present):

  • the SharePointURL could be set to [AssureSignCRM:SharepointURL]
  • the SharePoint Library could be set to [AssureSignCRM:Library]

However, for a more failsafe process, you could test to see that those values are present using javascript and merge fields.

The following sample that could be entered in the SharePoint URL text box tests whether the data from CRM is present, and if not it sets the URL to a fixed value:

[{var u = parameter('AssureSignCRM:SharepointURL'); return (!u|| 0 === u.length)?'':u;}]

The following sample that could be entered in the SharePoint Library text box tests whether the data from CRM is present, and if not it sets the library to a fixed value:

[{var l = parameter('AssureSignCRM:Library'); return (!l|| 0 === l.length)?'SignedDocuments':l;}

 SharePoint Storage Restrictions

The user credentials used to connect to SharePoint must have access to write to the document library. The document will overwrite the file if a file with the same name already exists. The document library must already exist; the process will not attempt to create a new folder in SharePoint.

SharePoint files (or folders) cannot contain any of the following characters:

~ # % & * { } \ : < > ? / | “

It would be possible to strip out illegal characters if they might exist in what you are attempting to write out to SharePoint with some javascript in the design.  For example, the following modified version of the previous examples includes a regular expression replacement of these characters in the file name by using something like the following advanced merge field syntax:

[{get('Document Name').replace(/[~#%&*:<>?|“"\{\}\\\/]/gi, '')}].signed.[{formatDate(get('Completion Date'), 'YYYY-MM-DD_hh-mm-ss')}].pdf