Merge and Store V2 in Zoho Writer
Description
The zoho.writer.v2.mergeAndStore task merges the document and stores it in a specific location in Zoho WorkDrive. This task is based on the Zoho Writer Merge and Store v2 API.
Creator users can use the Writer Merge and Store V2 Rest API with the invoke URL method.
Syntax
<response> = zoho.writer.v2.mergeAndStore(<document_id>, <merge_detail>, <output_settings>, <optional_settings>, <connection>)
where:
Params | Data type | Description |
<response> | KEY-VALUE | The response returned by Zoho Writer. It represents the merged document's details such as the merge data, along with the status of the merge. |
<document_id> | TEXT | The ID of the document which needs to be merged and stored in Zoho WorkDrive. The document ID can be obtained from the URL of the document which needs to be merged and stored in WorkDrive. The URL is in the following format: |
<merge_detail> | KEY-VALUE | Specify how your input for the merge will be. It can be JSON, CSV file, or a URL. |
<output_settings> | { 'doc_name': "<new document name>", 'folder_id': "<folder_id>" , 'output_format': "<pdfform/pdf/docx>", 'password': "<*****>", 'overwrite_existing_file': "<true/false>", 'merge_to':"<separatedoc/singledoc> } | Pass the values for doc_name and folder_id via this parameter as a JSON. doc_name: The name of the merged document. folder_id: Specify the id of the folder in which you would like to store the merged document. output_format (optional): The format in which you would like to store the merged document. Supported formats are PDF, PDFForm, and DOCX. Note: If this key is not passed, the merged documents will be stored in Writer's format (ZDOC) by default. password (optional): Specify a password if you would like to protect the merged document. This param is applicable only for PDF and DOCX documents. overwrite_existing_file (optional): Use this param, if you wish to replace an existing file stored in Zoho WorkDrive with the merged document. merge_to (optional): The type of document to be created from the merge. Supported merge types are separatedoc and singledoc. separatedoc: If you would like to merge each record as a separate document. singledoc: If you would like to merge all the records as a single document. Note: By default, we will apply separatedoc as the merge type. |
<optional_settings> | KEY-VALUE | The optional parameters you can send to merge and store according to your preference. |
<connection> | TEXT | The connection's link name. Note:
|
You can provide the merge_detail parameter in any one of the below formats:
Key | Value | Description |
---|---|---|
merge_data | JSONObject | Pass a String value through data key as JSON Array. |
merge_data_csv_content | File | Provide the required CSV content in your API request body. |
merge_data_json_content | File | Provide the required JSON content in your API request body. |
merge_data_csv_url | URL | Provide the required CSV URL in your API request body. |
merge_data_json_url | URL | Provide the required JSON URL in your API request body. |
option_settings parameter values:
Parameter | Data Type | Description |
sign_service_name | String |
Specify a third-party signing service name to make your merged document's signing fields compatible with. Possible values are zohosign, adobesign, and docusign. By default, the service will be zohosign.
|
test_mode | Boolean (true/false) | Using this parameter, you can test the Merge APIs without consuming any credit points. The output file will contain a watermark as it is used only for testing purposes. Test mode limit: 50 merges/day for an org. |
Note:
- To use this API, an OAuth token should be generated with the following scopes ZohoWriter.documentEditor.ALL and ZohoWriter.merge.ALL
- If you would like to store the documents (docx/pdf) inside a Workdrive/Docs folder, you need to include the following scopes accordingly;
- For Workdrive - WorkDrive.Files.ALL
- For Docs - ZohoPC.files.ALL
Example
The following script merges a document and stores it in a specific folder in Zoho WorkDrive.
document_id = "po5uobda049e029d44b13a9956f6d2cedc67b"; fields = Map(); fields.put("Name", "Ms.Amelia"); fields.put("Tamil", "S"); fields.put("English", "A"); fields.put("Maths", "A"); fields.put("Remark", "Good"); data_map = Map(); data_map.put("data", fields); merge_details = Map(); merge_details.put("merge_data", data_map); optional_settings= Map(); optional_settings.put("sign_service_name","zohosign"); optional_settings.put("test_mode", "true"); output_settings = Map(); output_settings.put("doc_name","Student Grade"); output_settings.put("folder_id","bsa6360a78f53f***"); //Workdrive Folder ID //optional output_settings.put("output_format","pdf"); //docx|pdfform|pdf //optional output_settings.put("password","*****"); //optional output_settings.put("overwrite_existing_file","true"); //true|false //optional response = zoho.writer.v2.mergeAndStore(document_id, merge_details, output_settings, optional_settings, "writer_oauth_connection"); info response;
Usecase
Scenario 1: Merge and store proposals
Say you're generating a proposal for a deal in CRM. Sales team generates a new proposal by merging it and saves it to a particular folder in WorkDrive.
document_id = "po5uobda049e029d4r98r84304jrj32"; fields = Map(); fields.put("ClientName", "Zylker"); fields.put("ClientCompany", "Writer"); fields.put("price", "10000"); data_map = Map(); data_map.put("data", fields); merge_details = Map(); merge_details.put("merge_data", data_map); optional_settings= Map(); output_settings = Map(); output_settings.put("doc_name","SALES PROPOSAL"); output_settings.put("folder_id","bsa6360a78f53f***"); //Workdrive Folder ID //optional output_settings.put("output_format","pdf"); //docx|pdfform|pdf //optional output_settings.put("password","*****"); //optional output_settings.put("overwrite_existing_file","true"); //true|false //optional response = zoho.writer.v2.mergeAndStore(document_id, merge_details, output_settings, optional_settings, "writer_oauth_connection"); info response;
Response Format
{ "merge_report_data_url": "<url>", "merge_report_url": "<url>", "records": [ { "data": [{“given input merge_data”}], "download_link": "<attachment download url>", "document_id": "<merged doc id>", "document_url": "<merged doc open url>", "status": "inprogress" } ], "status": "inprogress" }
Related Links
- Zoho Writer integration tasks
- Connections
- Zoho Writer - Merge and Store v2 API document
- Zoho Writer API - Possible error responses