Extension pointers for integrating Zoho CRM with Zoho products #9: Track and share Zoho WorkDrive files from within Zoho CRM

Extension pointers for integrating Zoho CRM with Zoho products #9: Track and share Zoho WorkDrive files from within Zoho CRM

Viewing and tracking WorkDrive files from within Zoho CRM ensures you have greater visibility and accessibility. 
 
In our previous post, we set up a Team Folder and contact-specific folders within it to upload files for each contact. In continuation of that post, let's look at how to view the files in a contact's related list by retrieving and listing all of the files in the contact's WorkDrive folder. This allows you to keep track of a contact's files without having to switch between WorkDrive and CRM.
 
In addition to maintaining files within the team, you can easily share files with contacts through email by using the Attach file from Zoho WorkDrive option. You can also create a custom external share link and share it with the user through chat if necessary. 
 
Connector APIs
 
The Zoho WorkDrive REST APIs added for the example are as follows:
 
Connector API Name
Method type
URL
Get files of a folder
GET
Create external share custom link
POST
 
Creating a related list for the Contacts module to display the files present in the contact's WorkDrive folder
  • Create a custom related list called "WorkDrive files" using the Related Details feature available in the Components section of the Zoho Developer console, then associate a function to perform the desired action.
WorkDrive files - Related list function code snippet
//Retrieving the contact record and fetching the full name
response = zoho.crm.getRecordById("Contacts",contact.get("Contacts.ID").toLong());
info response;
dynamic_map = Map();
folderid = response.get("testsupport__Folder_ID");
info folderid;
dynamic_map.put("file_folder_id",folderid);
 
/* Invoking the "Get files of a folder" API to get the files present in the folder ID updated in the custom field "Folder ID" of the record*/
filesresp = zoho.crm.invokeConnector("testsupport.WorkDrive.getfilesofafolder",dynamic_map);
filesresponse = filesresp.get("response");
filesdata = filesresponse.get("data");
finalresponse = "";
count = 1;
if(filesdata != null)
{
recordsXmlStr = "<record>";
for each value in filesdata
{
attributes = value.get("attributes");
dynamic_map = Map();
dynamic_map.put("resource_id",value.get("id"));
dynamic_map.put("link_name",attributes.get("name") + "-link");
/* Invoking the "Create external share custom link" API to create a custom share link to externally share the file*/
linkresp = zoho.crm.invokeConnector("testsupport.WorkDrive.createexternalsharecustomlink",dynamic_map);
linkresponse = linkresp.get("response");
linkdata = linkresponse.get("data");
linkattributes = linkdata.get("attributes");
recordsXmlStr = recordsXmlStr + "<row no='" + count + "'>";
recordsXmlStr = recordsXmlStr + "<FL val='Name'>" + attributes.get("name") + "</FL>";
recordsXmlStr = recordsXmlStr + "<FL val='Extension'>" + attributes.get("extn") + "</FL>";
recordsXmlStr = recordsXmlStr + "<FL val='Type'>" + attributes.get("type") + "</FL>";
recordsXmlStr = recordsXmlStr + "<FL val='Permalink'>" + attributes.get("permalink") + "</FL>";
recordsXmlStr = recordsXmlStr + "<FL val='External share link'>" + linkattributes.get("link") + "</FL>";
recordsXmlStr = recordsXmlStr + "</row>";
count = count + 1;
}
recordsXmlStr = recordsXmlStr + "</record>";
finalresponse = finalresponse + recordsXmlStr;
}
else
{
finalresponse = finalresponse + "<error>=><message>No files associated.</message></error>";
}
return finalresponse;
 
  • The above code snippet fetches the record details for the current contact to retrieve the custom field "Folder ID" value of the customer. 
  • The Folder ID is then delivered to the Get files of a folder API to retrieve files from the folder for the contact from Zoho WorkDrive.
  • These files are then displayed as a related list called "WorkDrive files" listing some relevant details like NameExtensionTypePermalink, and External share link.
  • External share link: The resource ID and the name retrieved from the result of the Get files of a folder API are delivered to the Create external share custom link API to create a custom link to share the file externally. 
Sample output
 
After uploading the files as depicted in the earlier post, click the WorkDrive files related list available in the CRM contact's record details page to view the files inside the contact's WorkDrive folder.
 

  • You can use the External share link to share files with the contact through chat individually.


You can also send the contact's files using the Email related list option. Since the integration functionality (create folder and upload files operations) performed in Zoho CRM is also synchronized in Zoho WorkDrive, you can easily select and share files with contacts in just a few clicks through email.

We hope you found this information helpful. Keep following this space for more advice!