For Zoho Services only:

I'm actually part of a bigger team at Ascent Business Solutions where we have support technicians and project consultants. Support is for smaller technical fixes but this can include developments, reports or integrations; depending on the size of the task. Projects are for more time-consuming developments such as revamps of the Zoho Suite of apps or on-site training. The advantage of a team is that if I am out-of-office for a day or so, there is always someone at Ascent Business Solutions who can deal with any queries/issues you may have.

Our support rates can be found and purchased at A support bundle doesn't have an expiry date. So whether we can do what you want within the bundle and a year later need further support, if there are minutes left on the bundle then there is no additional charge.

Our project rates for bigger developments can be found at and will involve a dedicated project consultant along with developers who will hold your hand through the development process.

If you want help building a solution for one of the Zoho Apps in the Zoho Suite, contact us on 0121 392 8140 (UK) or by email at You can also visit our website at

I regularly build and specialize in 2-way API integrations for Xero, Shopify and eBay.

Zoho CRM & Creator: Download attachment and upload to Creator file field

A super quick article on how to download an attachment from CRM and upload to a "file upload" field in Creator.

My use case here is that we are creating a Creator app that will show the attachments on a CRM contact record (and be clickable). The complication here is that the user can use the Creator form to add a new attachment that will eventually be uploaded back to CRM.

At time of print, things have moved on and based on the Zoho official forums, this used to be a daunting task. Not anymore at least from what I've seen.

You could try adding a subform to Creator but have it as a blank form rather than a bidirectional form as in this example, the parent record doesn't yet exist... The cheat here is that we actually want the user to be able to click and download/open the attachments on the CRM record from within the Creator app. As for the add a new attachment, well that's just functionality.

Here's my Creator form (well the part for the attachments):
  • An attachments section to hold a notes field.
  • A notes field called "Note_Attachments" (this will display a HTML table with click-to-download files)
  • A blank subform callled "Attachments" (links to a form called "Documents")
Zoho CRM & Creator: Download attachment and upload to Creator file field: Parent Creator Form

Here's the Creator form to hold the Attachments:
  • Parent Record (a single line that will be a unique ref to prevent downloading the same record again and again)
  • Document Name (a single line that will be the name of the file including its extension)
  • Document (the file upload field)
  • Downloaded (a picklist with the options "Downloaded" and "Pending Upload")
Zoho CRM & Creator: Download attachment and upload to Creator file field: Document Creator Form

Here's the code for the parent form to download the attachments and upload them to the Creator "Document" form:
// get attachments
v_NoteAttachments = "<table class='jl-table-info jl-table-attachments'>";
m_SortCriteria = Map();
l_Attachments = zoho.crm.getRelatedRecords("Attachments","Contacts",v_CrmContactID,1,200,m_SortCriteria);
for each  r_Attachment in l_Attachments
	if(r_Attachment.get("id") != null)
		v_AttachmentEndpoint = "" + v_CrmContactID + "/Attachments/" + r_Attachment.get("id");
		r_Download = invokeurl
			url :v_AttachmentEndpoint
			type :GET
		r_CheckIfDocumentAlreadyExists = Document[Parent_Record == v_CrmContactID.toString() && Document_Name == r_Attachment.get("File_Name")];
		if(r_CheckIfDocumentAlreadyExists.count() > 0)
			r_NewDocumentRecord = Document[ID == r_CheckIfDocumentAlreadyExists.ID];
			v_DateAdded = r_NewDocumentRecord.Added_Time.toString("E, d MMM yyyy HH:mm");
			r_Document = insert into Document
			r_NewDocumentRecord = Document[ID == r_Document];
			v_DateAdded = r_NewDocumentRecord.Added_Time.toString("E, d MMM yyyy HH:mm");
		v_LinkToDownload = "<a href='" + zoho.appuri + "All_Documents/" + r_NewDocumentRecord.ID + "/Document_File/download?filepath=/" + r_NewDocumentRecord.Document_File + "'>" + r_NewDocumentRecord.Document_Name + "</a>";
		v_NoteAttachments = v_NoteAttachments + "<tr><td>" + v_DateAdded + "</td><td style='font-weight:700;'>" + v_LinkToDownload + "</td></tr>";
v_NoteAttachments = v_NoteAttachments + "</table>";
input.Note_Attachments = v_NoteAttachments;
  1.  // 
  2.  // get attachments 
  3.  v_NoteAttachments = "<table class='jl-table-info jl-table-attachments'>"
  4.  m_SortCriteria = Map()
  5.  m_SortCriteria.put("sort_by","Created_Time")
  6.  m_SortCriteria.put("sort_order","desc")
  7.  l_Attachments = zoho.crm.getRelatedRecords("Attachments","Contacts",v_CrmContactID,1,200,m_SortCriteria)
  8.  for each  r_Attachment in l_Attachments 
  9.  { 
  10.      if(r_Attachment.get("id") != null) 
  11.      { 
  12.          v_AttachmentEndpoint = "" + v_CrmContactID + "/Attachments/" + r_Attachment.get("id")
  13.          r_Download = invokeUrl 
  14.          [ 
  15.              url :v_AttachmentEndpoint 
  16.              type :GET 
  17.              connection:"ab_crm" 
  18.          ]
  19.          r_Download.setParamName("file")
  20.          r_CheckIfDocumentAlreadyExists = Document[Parent_Record == v_CrmContactID.toString() && Document_Name == r_Attachment.get("File_Name")]
  21.          if(r_CheckIfDocumentAlreadyExists.count() > 0) 
  22.          { 
  23.              r_NewDocumentRecord = Document[ID == r_CheckIfDocumentAlreadyExists.ID]
  24.              v_DateAdded = r_NewDocumentRecord.Added_Time.toString("E, d MMM yyyy HH:mm")
  25.          } 
  26.          else 
  27.          { 
  28.              r_Document = insert into Document 
  29.              [ 
  30.                  Added_User=zoho.loginuser 
  31.                  Document_Name=r_Attachment.get("File_Name") 
  32.                  Document_File=r_Download 
  33.                  Downloaded="Downloaded" 
  34.                  Parent_Record=v_CrmContactID.toString() 
  35.              ]
  36.              r_NewDocumentRecord = Document[ID == r_Document]
  37.              v_DateAdded = r_NewDocumentRecord.Added_Time.toString("E, d MMM yyyy HH:mm")
  38.          } 
  39.          v_LinkToDownload = "<a href='" + zoho.appuri + "All_Documents/" + r_NewDocumentRecord.ID + "/Document_File/download?filepath=/" + r_NewDocumentRecord.Document_File + "'>" + r_NewDocumentRecord.Document_Name + "</a>"
  40.          v_NoteAttachments = v_NoteAttachments + "<tr><td>" + v_DateAdded + "</td><td style='font-weight:700;'>" + v_LinkToDownload + "</td></tr>"
  41.      } 
  42.  } 
  43.  v_NoteAttachments = v_NoteAttachments + "</table>"
  44.  input.Note_Attachments = v_NoteAttachments; 

Here's the code at the end of the parent form to hide the columns I don't need the user to see (I'll populate these by code):
hide Attachments.Parent_Record;
hide Attachments.Document_Name;
hide Attachments.Downloaded;
  1.  hide Attachments.Parent_Record; 
  2.  hide Attachments.Document_Name; 
  3.  hide Attachments.Downloaded; 

Here's the code I use when a "Addition of a row" workflow is triggered on that subform. This makes sure I don't download it again and create a new Creator record to hold the same file but in a new record, as well as include the marker to check when uploading the files back to CRM:
row.Downloaded="Pending Upload";
  1.  row.Parent_Record=input.CRM_Contact; 
  2.  row.Downloaded="Pending Upload"

Here's the code I use when uploading a file to the newly added row in that subform (on user input). This sets the document name for display later:
	v_FileDetected = row.Document_File;
		v_SubstringStart = v_FileDetected.indexOf("_");
		v_FilenameDetected = v_FileDetected.subString(v_SubstringStart + 1);
		v_FilenameFormatted = v_FilenameDetected.replaceAll("_"," ");
  1.  if(!isnull(row.Document_File)) 
  2.  { 
  3.      v_FileDetected = row.Document_File; 
  4.      if(v_FileDetected.contains("_")) 
  5.      { 
  6.          v_SubstringStart = v_FileDetected.indexOf("_")
  7.          v_FilenameDetected = v_FileDetected.subString(v_SubstringStart + 1)
  8.          v_FilenameFormatted = v_FilenameDetected.replaceAll("_"," ")
  9.          row.Document_Name=v_FilenameFormatted; 
  10.      } 
  11.  } 

And finally, with a bit of CSS, this is what the end product looks like:
Zoho CRM & Creator: Download attachment and upload to Creator file field: How it looks

Category: Zoho :: Article: 809

Credit where Credit is Due:

Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman

Related Articles

Joes Revolver Map


Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Donate to Joel Lipman via PayPal

Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 bc1qjtp4l4ra452wzvuk9a45yfj82zkahsyy2z379y
© 2023 Joel Lipman .com. All Rights Reserved.