How to pass the image field value when performing Mail Merge via API in Zoho CRM?

How to Pass Image Fields Values in Zoho CRM's Mail Merge via API?

When conducting a mail merge from Zoho CRM using our Merge APIs, if the merge template includes image fields, you'll need to construct the value for those image fields on your end. Zoho CRM will solely provide the Preview Image ID value for the image field, rather than the complete preview Image URL.

Please follow the below steps to construct the Image URL to pass as image field value;

1. Invoke Get Record API (version 5 and above) and get the Preview Image ID [Preview_Id__s] of that image field from the response. Using this Preview Image ID, you need to construct the image url as mentioned below.

Sample values to replace the variables in the snippet shared below:
Module = "Leads";   //Provide your respective module name
RecordId = "456789";   //CRM record id
RLModuleName = "Products";   //Related List Name
zohoapi_domain (for US DC) = "https://www.zohoapis.com";   //For other DCs, refer the API domains here.
Sample Snippet:

// get Records
recordInfo = invokeurl
[
url :zohoapi_domain+"/crm/v5/"+Module+"/"+RecordId;
type :GET
connection:"crm"
];
recordInfoData = recordInfo.get("data").get(0);
dataMap = Map();
dataMap.put("Email",recordInfoData.get("Email"));
dataMap.put("Last_Name",recordInfoData.get("Last_Name"));
// Image field
if(recordInfoData.get("Image_Upload") != null)
{
imageId = recordInfoData.get("Image_Upload").get(0).get("Preview_Id__s");
imageUrl = zohoapi_domain+"/crm/v2.1/__attachment_preview/" + imageId;    //constructed image url 
dataMap.put("Image_Upload",imageUrl);
}
info dataMap;

2. If image field is a RL record, then invoke this Related Records Data API (version 5 and above) to get the RL Record ID. Then, invoke the Get Records API with this RL Record ID to get the Preview Image ID.

Sample Snippet:

dataMap = Map();
 //Get Related List IDs
relatedListsIds = invokeurl
[
url:zohoapi_domain+"/crm/v5/"+Module+"/"+RecordId+"/"+RLModuleName+"?fields=Parent_Id"
type :GET
connection:"crm"
];
rlListData = relatedListsIds.get("data");
rlProductsList = List();
//Get Related List Data
for each  record in rlListData
{
rlId = record.getJSON("id");
rlInfo = invokeurl
[
url :zohoapi_domain+"/crm/v5/+"RLModuleName+"/" + rlId
type :GET
connection:"crm"
];
rlInfoData = rlInfo.get("data").get(0);
rlMap = Map();
rlMap.put("Product_Name",rlInfoData.getJSON("Product_Name"));
rlMap.put("Product_Code",rlInfoData.getJSON("Product_Code"));
//RL Image Field
if(rlInfoData.get("Image_Upload") != null)
{
rlImageId = rlInfoData.get("Image_Upload").get(0).get("Preview_Id__s");
imageUrl = zohoapi_domain+"/crm/v2.1/__attachment_preview/" + rlImageId;  //constructed image url
rlMap.put("Image_Upload",imageUrl);
}
rlProductsList.add(rlMap);
}
//Add Related List to dataMap
dataMap.put("Products",rlProductsList);
info dataMap;

    Access your files securely from anywhere

      Zoho CRM Training Programs

      Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

      Zoho CRM Training
        Redefine the way you work
        with Zoho Workplace

          Zoho DataPrep Personalized Demo

          If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

          Zoho CRM Training

            Create, share, and deliver

            beautiful slides from anywhere.

            Get Started Now


              Zoho Sign now offers specialized one-on-one training for both administrators and developers.

              BOOK A SESSION






                          Quick Links Workflow Automation Data Collection
                          Web Forms Enterprise Begin Data Collection
                          Interactive Forms Workplace Data Collection App
                          Offline Forms Customer Service Accessible Forms
                          Digital Forms Marketing Forms for Small Business
                          HTML Forms Education Forms for Enterprise
                          Contact Forms E-commerce Forms for any business
                          Lead Generation Forms Healthcare Forms for Startups
                          Wordpress Forms Customer onboarding Order Forms for Small Business
                          No Code Forms Construction RSVP tool for holidays
                          Free Forms Travel Kiosk in mobile app
                          Prefill Forms Non-Profit

                          Intake Forms Legal

                          Form Designer HR

                          Card Forms Food
                          Assign Forms Photography

                          Translate Forms Real Estate
                          Electronic Forms

                          Notification Emails for Forms Alternatives
                          Holiday Forms Google Forms alternative 
                          Form to PDF Jotform alternative





                                            You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                Manage your brands on social media

                                                  Zoho Desk Resources

                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                    Zoho Marketing Automation

                                                      Zoho Sheet Resources

                                                       

                                                          Zoho Forms Resources


                                                            Secure your business
                                                            communication with Zoho Mail


                                                            Mail on the move with
                                                            Zoho Mail mobile application

                                                              Stay on top of your schedule
                                                              at all times


                                                              Carry your calendar with you
                                                              Anytime, anywhere




                                                                    Zoho Sign Resources

                                                                      Sign, Paperless!

                                                                      Sign and send business documents on the go!

                                                                      Get Started Now




                                                                              Zoho TeamInbox Resources



                                                                                      Zoho DataPrep Resources



                                                                                        Zoho DataPrep Demo

                                                                                        Get a personalized demo or POC

                                                                                        REGISTER NOW


                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now









                                                                                                              • Related Articles

                                                                                                              • How to merge subform fields and image field with Zoho Writer's Merge APIs in Zoho CRM

                                                                                                                How to merge subform fields via Merge API's in Zoho Writer 1. Create a Merge template in Writer with related (RL) fields Sample Merge Template consisting of both Normal and RL fields: Hello <<Contacts.First Name>> Send a mail to <<Contacts.Email>> ...
                                                                                                              • How to use Zoho WorkDrive images into Writer merge fields?

                                                                                                                Zoho Writer only accepts Public URL for the image fields in Mail merge. If the images are stored in Zoho WorkDrive, you can create a downloadable link and use it as an input value for the image field. This can be done in the following three ways; a) ...
                                                                                                              • Finish Merge

                                                                                                                Finish Actions Email Notifications You can enable email notifications to get notified when the merge is initiated and completed. You will receive an email as shown below, once the merge is initiated with a link to track the status of the merge ...
                                                                                                              • Working with Fields

                                                                                                                Supported field types Supported field types Description Possible Values in the data source Rendered as Notes Plain Text The value of the field is placed as a string in the document. “test” “test” You can select the field in the document and apply the ...
                                                                                                              • How to create workflow rules in Zoho CRM to perform mail merge tasks

                                                                                                                You can automate your Writer's mail merge tasks by creating Workflow rules in your Zoho CRM. Say, for example, you want to automate the merge and send task for every lead entry in your Zoho CRM account (merge every lead entry send an email ...
                                                                                                                Wherever you are is as good as
                                                                                                                your workplace

                                                                                                                  Resources

                                                                                                                  Videos

                                                                                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                  eBooks

                                                                                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                  Webinars

                                                                                                                  Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                  CRM Tips

                                                                                                                  Make the most of Zoho CRM with these useful tips.



                                                                                                                    Zoho Show Resources