Request Token URL | https://accounts.zoho.com/oauth/v2/auth?scope=,WorkDrive.users.READ,WorkDrive.files.CREATE, WorkDrive.teamfolders.CREATE&access_type=offline |
Access Token URL | https://accounts.zoho.com/oauth/v2/token |
Refresh Token URL | https://accounts.zoho.com/oauth/v2/token |
Scopes | WorkDrive.users.READ,WorkDrive.files.CREATE, WorkDrive.teamfolders.CREATE |
Connector API Name | Method type | URL |
Get ZUID | GET | https://www.zohoapis.com/workdrive/api/v1/users/me |
Get all teams of a user | GET | https://www.zohoapis.com/workdrive/api/v1/users/${zuid}/teams |
Create team folder | POST | https://www.zohoapis.com/workdrive/api/v1/teamfolders |
Create new folder | POST | https://www.zohoapis.com/workdrive/api/v1/files |
File upload | POST | https://www.zohoapis.com/workdrive/api/v1/upload?filename=${file_name}&parent_id=${file_parent_id}&override-name-exist=true |
Util={}; var teamidvalue; //Subscribe to the EmbeddedApp onPageLoad event before initializing the widget ZOHO.embeddedApp.on("PageLoad",function(data) { var data = { } //Invoking the 'Get ZUID' API to retrieve the user's ZUID ZOHO.CRM.CONNECTOR.invokeAPI("xxx.workdrive.getzuid",data) .then(function(dataa){ console.log(dataa); response = dataa.response responsejson=JSON.parse(response); zuiddata=responsejson.data; zuid=zuiddata.id; var data = { "zuid" : zuid } //Invoking the 'Get all teams of a user' API to fetch all the teams of a user ZOHO.CRM.CONNECTOR.invokeAPI("xxx.workdrive.getallteamsofauser",data) .then(function(dataa){ console.log(dataa); response = dataa.response; responsejson=JSON.parse(response); teamdata=responsejson.data; for (i = 0; i < teamdata.length; i++) { teamid=teamdata[i].id; attributes=teamdata[i].attributes; teamname=attributes.name; var teamlist = document.getElementById("teamlist"); var option = document.createElement("OPTION"); option.innerHTML = teamname; option.value = teamid; teamlist.appendChild(option); } }) }) }) Util.getvalues=function() { //Retrieving the value chosen in the teamlist teamidvalue=document.getElementById("teamlist").value; /*Constructing data and passing to 'Create team folder' API to create a team folder called "CRM Contacts test"*/ var data = { "extension_team_folder_name" : "CRM Contacts test", "parent_id":teamidvalue } ZOHO.CRM.CONNECTOR.invokeAPI("xxx.workdrive.createteamfolder",data) .then(function(dataa){ console.log(dataa); response = dataa.response; responsejson=JSON.parse(response); teamfolderdata=responsejson.data; teamfolderid=teamfolderdata.id; //Set the ID of the team selected in the teamlist to the "Team Folder ID" CRM variable var variableMap = { "apiname": "xxx__Team_Folder_ID", "value": teamfolderid}; ZOHO.CRM.CONNECTOR.invokeAPI("crm.set", variableMap); ZOHO.CRM.API.getOrgVariable("xxx__Team_Folder_ID").then(function(data){ console.log(data); }); }); } |
//Fetching the current contact details and retrieving the Full Name and custom field folder ID of the contact response = zoho.crm.getRecordById("Contacts",contact.get("Contacts.ID").toLong()); Fullname = response.get("Full_Name"); contactfolderid = response.get("xxx__Folder_ID"); if(contactfolderid == null) { /*Invoking the 'Create new folder' API to get create a folder in Workdrive for the Zoho CRM contact with the name as their Full Name*/ parentfolderid = zoho.crm.getOrgVariable("xxx__Team_Folder_ID"); dynamic_map = Map(); dynamic_map.put("name",Fullname); dynamic_map.put("folder_parent_id",parentfolderid); newfolderresp = zoho.crm.invokeConnector("xxx.workdrive.createnewfolder",dynamic_map); newfolderresponse = newfolderresp.get("response"); newfolderdata = newfolderresponse.get("data"); newfolderid = newfolderdata.get("id"); contactinfo = {"xxx__Folder_ID":newfolderid}; /* Updating the 'Folder ID' custom field in contact's record with the new folder ID obtained from the response*/ folderresponse=zoho.crm.updateRecord("Contacts",contact.get("Contacts.ID").toLong(),contactinfo); return "A new workdrive folder has been created with the ID - " + newfolderid; } else { return "Folder already present for contact in Workdrive"; } |
Writer is a powerful online word processor, designed for collaborative work.