How to use the record_id parameter in Zoho Writer's merge templates
The record_id parameter in Zoho Writer's merge templates allows you to easily fetch the values of the desired fields based on the record_id value. With this new parameter, you do not have to manually map every field used in the template in your Deluge code.
Prerequisites for using the record_id parameter
Ensure these conditions are met before using the record_id parameter:
- You should have connected your merge template to a data source.
- You should have the necessary permissions to fetch records from the data source.
- You must have sufficient automation credits to generate documents. Learn more about credits and pricing.
Zoho apps supported by the Merge APIs
At the moment, the Merge APIs integrate with these Zoho apps to fetch the relevant records using the record_id:
- Zoho CRM
- Zoho Creator
- Bigin
- Zoho Recruit
Sample Code
Here’s an example of how to use the record_id parameter in a Deluge code to merge a specific record from Zoho CRM into a Writer template:
- document_id = "4tx4ie20882e93a3b40a58a613213b5491b99";
- recordId = "154845000004785001";
- outputsettings = Map();
- outputsettings.put("doc_name","Student Grade PDF");
- outputsettings.put("folder_id","mt3vx64b53cadf1dxxxxxxxxxxx");
- outputsettings.put("output_format","pdf");
- param = Map();
- param.put("record_id",recordId);
- param.put("output_settings",outputsettings);
- response = invokeurl
- [
- url :"https://zohoapis.com/writer/api/v2/documents/1mg03e345d3ecbe4241958089f6cd9a55421d/merge/store"
- type :POST
- parameters:param
- connection:"writercrm"
- ];
- info response;
This Deluge code fetches the data for the given record_id and merges it into the document template to dynamically generate a personalized document.
Benefits of the record_id parameter
- The required records and their fields are fetched and mapped automatically using the record ID
- The process is accurate and error-free
- Automation saves time and effort
Refer
this forum post to learn how record_id parameter simplifies Deluge code.