Building a Google Drive - Related List Widget
Embedding a Google Drive widget inside Zoho CRM as a Related list allows a user to accomplish three tasks,
- Fetch files from Google Drive and show them as a related list in the record's detail page in CRM.
- Upload any document from Zoho CRM to a Google Drive folder.
- Retrieve file information from the Google Drive.
How can I ...
Import the Zoho JS SDK
To import the Zoho JS SDK,visit https://github.com/ZohoDevelopers/GoogleDriveWidget, download and extract it to your path.
Register the Event Listeners
Registering an event means defining a function that will be executed when certain event is triggered by your application.
The code for event listener for this application is,
})
The code to initialize SDK is,
The code to invoke an API is
});
Authentication using OAuth2
This extension is authenticated using OAuth2.0 protocol. The Google Drive connector is created with the necessary APIs associated with this extension and published.
Create and Authenticate an Extension
- Log in to Zoho Developer Console and click Extensions for Zoho CRM.
- Create an extension and name it 'Google Drive'.
- Click Connectors in the left pane and go to All Connectors tab.
- Click the Create Connector button, and provide the details to create the connector. Add the necessary API's to the connectors. Refer this page for details of how to create a Connector.
Refer below table for details of the APIs:
Name API URL getFiles https://www.googleapis.com/drive/v2/files/${folderId}/children uploadFile https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart getFileInfo https://www.googleapis.com/drive/v2/files/${fileID} - Add the connector to your extension.
Create Custom Components
- Create a custom field named DriveFolderID in the Leads Module to store an auto-generated folder ID whenever a lead record is created.
- Create a Related List titled Google Drive in the Leads module to fetch the files from Google Drive.
Set up a Connected App
- Click Connected Apps in the left pane of the Extension details page.
- Enter the following information:
- Connected App Name : Google Drive
- Description : A short description about the connected app.
- Choose Hosting : select the Server side application.
- Specify Base URL : https://live.zwidgets.com/GoogleDriveRL/v1/html/
- Click Save.
- A Connected App is now created.
Test your Application
- Click Test Your Extension located in the top right corner of the Zoho Developer Console.
- Create a new lead record in the Sand Box with the mandatory input information.
- Click Save. You can view the DriveFolderID value getting auto-generated.
- Click the Google Drive related list in lead's detail page. No files have been uploaded to the list yet.
- Add however many files to the list that you want upload.
- Your Google Drive related list is now updated!