ZOHO.CRM.HTTP.post(request) |
Name | Type | Description |
params | Object | Request parameters to be constructed to invoke HTTP POST. |
headers | Object | Request headers required. |
body | Object | Request parameters to be constructed to invoke HTTP POST. |
Util={}; var orgVal; var json; var jsonObj; var EntityId; var EntityName; var rec3; var wid="11**********71"; //hardcoded the workspace id for demonstration purposes var projname; function initializeWidget() { //Subscribe to the EmbeddedApp onPageLoad event before initializing the widget ZOHO.embeddedApp.on("PageLoad",function(data) { EntityName=data.Entity; EntityId=data.EntityId; console.log(EntityId); console.log(EntityName);. //Fetching deal related details using getRecord API ZOHO.CRM.API.getRecord({Entity:EntityName,RecordID:EntityId}) .then(function(data){ console.log(data) projname= data.data[0].Deal_Name; }) /*The personal access token of Asana has been stored in custom variable and retrieved using the getOrgVariable method */ ZOHO.CRM.API.getOrgVariable("jssdkextension__Accesskey").then(function(data){ org=data.Success; orgVal="Bearer "+org.Content; console.log (org.Content); console.log(orgVal); }) Util.create=function() { setTimeout(function(){ /*Constructing the request parameter (header and body) to pass to the HTTP POST method */ var request ={ headers:{ Authorization : orgVal, }, //Field values to create a project in Asana are passed in the body section body: { "data": { "name": projname, "start_on": document.getElementById("dateproject").value, "due_date": document.getElementById("lastdateproject").value, "notes": document.getElementById("notes").value, }, } } // Invoke the HTTP POST to create the project ZOHO.CRM.HTTP.post(request) .then(function(data){ jsonObj = JSON.parse(data); console.log(jsonObj); rec3=jsonObj.data.gid; console.log(rec3); }) },500) } }) //Initialize the widget ZOHO.embeddedApp.init(); } |
ZOHO.CRM.HTTP.get(request) |
Name | Type | Description |
params | Object | Request parameters to be constructed to invoke HTTP GET. |
headers | Object | Request headers required. |
Util={}; var orgVal; var json; var jsonObj; var rec; var pid="1**********3"; //hardcoded the project id for demonstration purposes function initializeWidget() { //Subscribe to the EmbeddedApp onPageLoad event before initializing the widget ZOHO.embeddedApp.on("PageLoad",function(data) { /*The personal access token of Asana has been stored in custom variable and retrieved using the getOrgVariable method */ ZOHO.CRM.API.getOrgVariable("jssdkextension__Accesskey").then(function(data){ org=data.Success; orgVal="Bearer "+org.Content; console.log (org.Content); console.log(orgVal); }) setTimeout(function(){ /*Constructing the request parameters to pass to the HTTP GET method for fetching tasks associated to the specific project*/ var request ={ headers:{ Authorization : orgVal, } } // Invoke the HTTP GET to receive the response of the initiated request ZOHO.CRM.HTTP.get(request) .then(function(data){ jsonObj = JSON.parse(data); console.log(jsonObj); rec=jsonObj.data; console.log(jsonObj.data); //Looping through every task detail and retrieving the task names for (i = 0; i < rec.length; i++) { /*Creating a list and populating the task name of the different tasks associated with the respective project*/ var taskname=rec[i].name; var node = document.createElement("LI"); var textnode = document.createTextNode(taskname); node.appendChild(textnode); document.getElementById("myList").appendChild(node); } }) },500) }) //Initialize the widget. ZOHO.embeddedApp.init(); } |