Merge and store document in Zoho Writer
Table of Contents
Description
The zoho.writer.mergeAndStore task supplies values to the merge fields inserted to a document, and stores the new merged documents converted into a single file in the specified Zoho Docs folder.
This integration task is based on the Zoho Writer API - Merge and store.
Syntax
<response> = zoho.writer.mergeAndStore(<document_id>, <values_map>, <output_settings>, <connection>);
| Params | Data type | Description |
<response> | KEY-VALUE | The response that represents the document ID and document URL. |
<document_id> | TEXT | The ID of the source document that will be merged with values. The document ID can be obtained from the URL of the source document. The URL is in the following format: |
<values_map> | KEY-VALUE / LIST of KEY-VALUE | The values that will be supplied to the merge fields. Note: Keys for this parameter should be the names of the merge fields inserted in the document. To fetch the names of the merge fields, you can use Zoho Writer's get merge fields integration tasks. |
<output_settings> | KEY-VALUE | Other output settings like the folder in which the new merged documents will be stored, the name of the new merged document, etc. Note: Keys for this parameter should be supplied as specified in Zoho Writer API document listed under output_settings param. |
<connection> | TEXT | The link name of the connection. Note:
|
Example: Supply data to the merge field and store the new document in the specified folder
The following script supplies the data stored in the KEY-VALUE variable - data_map to the merge fields present in the document of ID - al296XXXXXXXXXXXXXXXXXXXXXXXXXXXa516c, and stores the file in the specified Zoho Docs folder.
// Construct a KEY-VALUE variable to hold the merge data values_map = Map(); values_map.put("Name", "Shawn"); // Construct a KEY-VALUE variable to hold the output settings output_settings = Map(); output_settings.put("doc_name", "New merged document"); output_settings.put("folder_id", "5rh8dXXXXXXXXXXXXXXXXXXXXXXXXXXX98bbc"); // Perform the Merge and store task response = zoho.writer.mergeAndStore("al296XXXXXXXXXXXXXXXXXXXXXXXXXXXa516c", values_map, output_settings, "writer_oauth_connection");
where:
response
"al296XXXXXXXXXXXXXXXXXXXXXXXXXXXa516c"
variable_map
merge_value
"writer_oauth_connection""doc_name" "folder_id"
Response Format
Success Response
The success response will be returned in the following format:
{
"document_id":"eecb1aeaa73f630014520917adf2bbf3e95d7",
"document_url":"https://docs.zoho.com/file/eecb1aeaa73f630014520917adf2bbf3e95d7"
}
Failure Response
The failure response for incorrect document ID will be returned in the following format:
{
"error": {
"message": "Permission denied. You are not authorized to perform this operation.",
"documentation_url": "https://www.zoho.com/writer/help/api/v1/general-errors.html",
"response_generated_time": 1588604646315,
"request_url": "https://writer.zoho.com/api/v1/documents/hey6hccde919ddf4f4026138ee50e48f8df/merge/store",
"errorcode": "R5010"
}
}