Merge and store document

Merge and store document in Zoho Writer

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.

Note: On average, it takes about a minute to index a file/folder after it is created or updated. This indexing time can increase if the queue size increases. You will not get the expected result if you execute zoho.writer.mergeAndStore task before the document you need to merge is indexed.

Syntax

<response> = zoho.writer.mergeAndStore(<document_id>, <values_map>, <output_settings>, <connection>);
where:
ParamsData typeDescription

<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:
https://writer.zoho.com/writer/open/<document_id>

<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:

  • In view of stopping new authtoken generation, a Zoho OAuth connection with appropriate scopes is mandatory in order for new integration tasks (created after the deadline specified in the post) to work as expected. Existing integration tasks will continue to work with or without the connections parameter until you manually delete the authtoken from accounts.
  • Add relevant scopes mentioned in Zoho Writer API while creating the connection.
  • Refer to this post for the list of Zoho services that support the connections page.
  • Learn more about connections

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
The KEY-VALUE response that represents the document ID and URL.
"al296XXXXXXXXXXXXXXXXXXXXXXXXXXXa516c"
The TEXT that represents the ID of the document.
variable_map
The KEY-VALUE variable that holds the merge data.
merge_value
The KEY-VALUE variable that holds the name of the new document and the ID of the Zoho Docs folder in which the new merged document will be stored.
"writer_oauth_connection"
The TEXT that represents the name of the connection.
"doc_name" 
"folder_id" 
The TEXT keys that as specified in the Zoho Writer API.

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"
     }
     }

Related Links

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com