Document Enable Sessions

The Document Advanced Settings section provides access to more complex and detailed configuration options for your document.

Image Description

The Enable Sessions advanced setting from Document Advanced Settings is another very powerful feature that Documerge offers.

The Enable Sessions feature is a tool for managing complex document merges that require input from multiple data sources. This functionality is particularly useful when merging documents that depend on data from different systems. By assigning a unique session key to merge request, you can establish specific conditions that must be met before the document merge is fully processed.

For example, you might have a scenario where a document needs both a first name and a last name to be present before the merge can be completed. You can initiate the merge by sending a request with just the first name and the session key, which triggers the system to start the process but hold off on completing it. The merge will only be finalized once a second request, containing now the last name along with the session key, is received.

This approach ensures that the document is only merged when all necessary information is available, preventing incomplete merges and allowing for greater flexibility in how you manage and combine data across different systems. By leveraging the session key, the system seamlessly integrates data from various sources, ensuring that your documents are accurate and fully populated before the merge is finalized.

When setting up a session value, you specify a parameter or field that DocuMerge should use to track the merge. This parameter acts as a unique identifier, ensuring that the system knows which data belongs to which session. If this session parameter is not provided, the document merge will proceed using the data from that single request without waiting for additional information.

We will demonstrate this below with an example.

First we will enable Enable Sessions and add a _session key to our Document. As said before you can name this key however you want:

Once this is configured, we will define the specific conditions that must be met for the system to proceed with the merge. In this case, we will set a condition requiring that both the first_name and last_name fields have a value in the merged data for the merge to be fully executed. You can select any of the merged fields.

Afterward, we’ll copy the Merge URL from the Document Merge Tab and send a request to that endpoint using a tool like Postman or Insomnia to demonstrate the process. We will send a POST request to the URL with two parameters only first_name and _session:

The response will indicate that the current merge is pending, awaiting additional information before it can proceed.

Since we included the _session parameter matching the one specified in the Enable Sessions Advanced Settings, the system will automatically evaluate the conditions we set to determine whether the merge should proceed. In this example, we’ve specified that both $first_name and $last_name must have values. Since we send a request containing only $first_name, the merge will wait until all conditions are met before processing the document. If we check on Recent Merges too we will see that the document merge has a status of waiting:

Clicking on View Data will show current document merge data that was received:

How let’s assume we are sending another request to that same endpoint that has same _session key but now includes $last_name:

Documerge will automatically know how to combine these two requests into one and will proceed with document merge. If you now go to Recent Merges you can see now that merge has been completed.

And if you click on View Data you can check the data that was combined and sent to document merge for completing the merge:


Tags: , , , ,

Was this article helpful to you?

Yes No

Related Articles