Note: Zoho Projects follows OAuth2.0 protocol for authentication mechanism. You can refer to this post to understand the steps to register Zoho Projects and retrieve your client credentials.
Request Token URL | https://accounts.zoho.com/oauth/v2/auth?scope=ZohoProjects.portals.READ,ZohoProjects.users.READ,ZohoProjects.tasks.CREATE,ZohoProjects.projects.READ,ZohoProjects.tasks.READ&access_type=offline |
Access Token URL | https://accounts.zoho.com/oauth/v2/token? |
Refresh Token URL | https://accounts.zoho.com/oauth/v2/token? |
Scopes | ZohoProjects.portals.READ,ZohoProjects.users.READ,ZohoProjects.tasks.CREATE,ZohoProjects.projects.READ,ZohoProjects.tasks.READ |
Connector API Name | Method type | URL |
Get Portals | GET | https://projectsapi.zoho.com/restapi/portals/ |
Get Project Users | GET | https://projectsapi.zoho.com/restapi/portal/${portalid}/projects/${projectid}/users/ |
Create task | POST | https://projectsapi.zoho.com/restapi/portal/${portalid}/projects/${projectid}/tasks/?name=${name}&description=${description}&priority=${priority}&person_responsible=${person_responsible} |
Add comment for task | POST | https://projectsapi.zoho.com/restapi/portal/${portalid}/projects/${projectid}/tasks/${taskid}/comments/?content=${content} |
//Fetching the current record details and retrieving the necessary field information response = zoho.crm.getRecordById("Cases",case.get("Cases.ID").toLong()); Name = response.get("Subject"); Name = zoho.encryption.urlEncode(Name); Description = response.get("Description"); Description = zoho.encryption.urlEncode(Description); Priority = response.get("Priority"); Comments = response.get("Internal_Comments"); Comments = zoho.encryption.urlEncode(Comments); dynamic_map = Map(); /*Fetching the values for Portal ID and Project ID CRM variables which are obtained as part of the settings widget*/ portalid = zoho.crm.getOrgVariable("xxx__Portal_Id");//The api name of the CRM variable for Portal_Id projectid = zoho.crm.getOrgVariable("xxx__Project_Id");//The api name of the CRM variable for Project_Id dynamic_map.put("portalid",portalid); dynamic_map.put("projectid",projectid); //Invoking the connector API to retrieve the users present in the project resp1 = zoho.crm.invokeConnector("xxx.zohoprojects.getprojectusers",dynamic_map); response1 = resp1.get("response"); users = response1.get("users"); rolelist = List(); /*retrieving the ID of the user with admin role in the project to be assigned as the person responsible for the task*/ for each value in users { if(value.get("role") == "admin") { id = value.get("zpuid"); } } dynamic_map = Map(); portalid = zoho.crm.getOrgVariable("xxx__Portal_Id"); projectid = zoho.crm.getOrgVariable("xxx__Project_Id"); dynamic_map.put("portalid",portalid); dynamic_map.put("projectid",projectid); dynamic_map.put("name",Name); dynamic_map.put("description",Description); dynamic_map.put("priority",Priority); dynamic_map.put("person_responsible",id); /*Invoking the connector API with the necessary parameters passed to create a project task */ resp = zoho.crm.invokeConnector("xxx.zohoprojects.createtask",dynamic_map); response2 = resp.get("response"); tasks = response2.get("tasks"); //Retrieving the task id from the response of create task API for each ids in tasks { id1 = ids.get("id"); } dynamic_map = Map(); portalid = zoho.crm.getOrgVariable("xxx__Portal_Id"); projectid = zoho.crm.getOrgVariable("xxx__Project_Id"); dynamic_map.put("portalid",portalid); dynamic_map.put("projectid",projectid); dynamic_map.put("taskid",id1); dynamic_map.put("content",Comments); //Invoking the connector API to add a comment to the task response3= zoho.crm.invokeConnector("xxx.zohoprojects.addcommentfortask",dynamic_map); caseinfo = {"Solution":url}; response4 = zoho.crm.updateRecord("Cases",case.get("Cases.ID").toLong(),caseinfo); return resp; |
Util={}; var portalidvalue; var projectidvalue; //Subscribe to the EmbeddedApp onPageLoad event before initializing the widget ZOHO.embeddedApp.on("PageLoad",function(data) { var data = { } //Invoking the connector API to get portals of the user and populate them in a select list ZOHO.CRM.CONNECTOR.invokeAPI("testextensioncrm.zohoprojects.getportals",data) .then(function(dataa){ response = dataa.response; responsejson=JSON.parse(response); portal=responsejson.portals; for (i = 0; i < portal.length; i++) { portalid=portal[i].id_string; portalname=portal[i].name; var portallist = document.getElementById("portallist"); var option = document.createElement("OPTION"); option.innerHTML = portalname; option.value = portalid; portallist.appendChild(option); } }) /*Fetching the projects associated to the portal selected on click of the "Get Projects" button*/ Util.getproject=function() { portalidvalue=document.getElementById("portallist").value; var data = { "portalid" : portalidvalue } /*Invoking the connector API to get projects of the user with respect to the portal chosen and populate them in a select list*/ ZOHO.CRM.CONNECTOR.invokeAPI("testextensioncrm.zohoprojects.getprojects",data) .then(function(dataa){ response = dataa.response; responsejson=JSON.parse(response); project=responsejson.projects; $('#projectlist').empty(); for (j = 0; j < project.length; j++) { projectid=project[j].id_string; projectname=project[j].name; var projectlist = document.getElementById("projectlist"); var option = document.createElement("OPTION"); option.innerHTML = projectname; option.value = projectid; projectlist.appendChild(option); } }) } /*Updating the values of the portal ID and project ID selected in the select list to the CRM variables*/ Util.getvalues=function() { portalidvalue=document.getElementById("portallist").value; projectidvalue=document.getElementById("projectlist").value; var variableMap = { "apiname": "testextensioncrm__Portal_Id", "value": portalidvalue}; ZOHO.CRM.CONNECTOR.invokeAPI("crm.set", variableMap); var variableMap = { "apiname": "testextensioncrm__Project_Id", "value": projectidvalue}; ZOHO.CRM.CONNECTOR.invokeAPI("crm.set", variableMap); }); }); } }) |
Writer is a powerful online word processor, designed for collaborative work.