Extension Pointers - JS SDK series #4: Managing data from a widget using ZOHO.CRM.HTTP

Extension Pointers - JS SDK series #4: Managing data from a widget using ZOHO.CRM.HTTP

Handling and managing the data between two applications is a major factor for an efficient business. There are a variety of ways to handle data between Zoho CRM and other third-party applications. You can use deluge CRM tasks, create connectors, use API tokens or JS SDK based on your business requirements. In this post, let's take a look at how the JS SDKs help manage data using a widget. 

The JS SDK ZOHO.CRM.HTTP supports different HTTP methods and allows you to make Ajax calls from a widget.

The different HTTP methods are:
  • GET - To retrieve data/resources from the resource server.
  • DELETE - To delete a resource at a particular location. 
  • PATCH - To update a specific detail of the resource. This method updates the target resource with the provided content without changing other data. 
  • POST - To insert or upload any new resource to the server.
  • PUT - To update an existing resource. This replaces the target resource with the updated content.
In this post, let's assume a couple of scenarios that may be involved in an integration between Zoho CRM and Asana, a project management application. Let's explore how the HTTP methods GET and POST can be invoked from a widget while implementing the integration.

Consider a service-based software development company that manages its sales cycle in Zoho CRM and project management in Asana. Once they close a deal for a new app development, they kickstart their work and handle the project development and management processes in Asana. An integration between these two services can handle some valid use cases.

Scenario 1: Let's assume that a new project will be created in Asana as soon as a deal is closed in Zoho CRM. In this case, the details about the new project will need to be added into Asana with information from the Deals module of Zoho CRM in order to continue project management in Asana.

Lets see how to achieve this scenario using ZOHO.CRM.HTTP.post JS SDK.

Syntax: HTTP POST

ZOHO.CRM.HTTP.post(request)

Here request is the request object constructed with the following details:

Request Object

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.

createproject.js Code snippet:

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();
}

In this above code snippet, the Asana API to create a project is used. The deal-related details are fetched using getRecord Zoho CRM API. The fetched deal name, along with the input values (project start date, project due date and project notes), are constructed and passed to the body parameter of the API call. The project is created upon clicking the 'Create project in asana' button. Similarly, you can modify and enhance the above functionality according to your business needs.



Scenario 2: Assume after creating the project in Asana you have gone ahead and added some tasks for that project in Asana to manage the project. Now, while you're looking at the Zoho CRM contact associated with this particular project, you'd like to look at the tasks associated with that project, from within Zoho CRM itself.

Lets see how to achieve this scenario using ZOHO.CRM.HTTP.get JS SDK.

Syntax: HTTP GET

ZOHO.CRM.HTTP.get(request)

Here request is the request object constructed with the following details:

Request Object

Name
Type
Description
params
Object
Request parameters to be constructed to invoke HTTP GET.
headers
Object
Request headers required.

associatedTasks.js Code snippet:

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();
}

In the above code snippet, we used the Asana APIs to get tasks. The list of tasks for a particular project is fetched using the get tasks API and populated in a list. Similarly, you can modify and enhance the above functionality according to your business needs.



In this way, you can use the JS SDK ZOHO.CRM.HTTP to manage data through different HTTP methods. We hope you found this information useful. Keep following for more inputs.

SEE ALSO


      • Recent Topics

      • Create Funnel to Track Email Outreach Conversion

        Hello, We would like to create a funnel that measures: N° of emails sent -> N° of emails opened -> N° of emails responded We would like to measure this email response conversion rate for each of our SDRs. We use the analytics tool of Zoho CRM and not
      • Data Model - CRM Adjusting size of Entity boxes

        (Sorry if duplicate, previous post seems to have disappeared.) I am viewing the Data Model for CRM, and while it is great to see such a model, there is an obstacle. Many of the entities show only a subset of their fields. The entity boxes have scrollbars
      • Mapping a new Ticket in Zoho Desk to an Account or Deal in Zoho CRM manually

        Is there any way for me to map an existing ticket in Zoho desk to an account or Deal within Zoho CRM? Sometimes people use different email to put in a ticket than the one that we have in the CRM, but it's still the same person. We would like to be able
      • Zoho CRM - Analytics: How Can I Set Monday as First Day of The Week?

        Hello, In the analytics section of our Zoho CRM (not Zoho Analytics), we would like to track our SDRs' outreach activity. However, it appears that Zoho CRM treats Sunday as the first day of the week for the "This Week" and "Previous Week" filters. How
      • CRM Hack #3: How to update formula functions for already created records.

        Hello everyone! It’s Wednesday and we are back with yet another hack.. I'm sure you've used formula fields to meet some requirements specific to your business. Let's consider an example each for external (customer-facing) and internal facing scenarios
      • Location functionality now deletes bundle information if changed

        With the introduction of Locations, we are experiencing several issues. 1. When bundling an item, the 'default' is to the organisation, not a location. This is not a significant issues, other than when you change the value, any batch tracking information
      • Email with uppercase letters causes problem with portal

        Hello, When my customers register on a form, if they use uppercase letters in their email adress it causes problem with the portal. When I send the invitation for the portal, all letters are automatically modified in lowercase by the system, and when
      • Improved RingCentral Integration

        We’d like to request an enhancement to the current RingCentral integration with Zoho. RingCentral now automatically generates call transcripts and AI-based call summaries (AI Notes) for each call, which are extremely helpful for support and sales teams.
      • Is Zoho Abandoning Zapier Integrations in Favor of Flow?

        I recently invested in a paid Zapier account to automate key parts of my Zoho workflows, but I’m hitting roadblocks. Zoho’s automation tool, Flow, clearly gets the lion’s share of development effort, and their Zapier connectors feel neglected. When I
      • Create custom rollup summary fields in Zoho CRM

        Hello everyone, In Zoho CRM, rollup summary fields have been essential tools for summarizing data across related records and enabling users to gain quick insights without having to jump across modules. Previously, only predefined summary functions were
      • Zoho Flow y subformularios de Zoho CRM

        Buenas tardes, En mi empresa vamos a empezar a usar los subformularios de zoho crm pero estos los voy a tener que rellenar con zoho flow ya que va a ser el encargado de rellenar dichos campos del subformulario. El problema es que a la hora de intentar
      • FSM Job Sheets data to CRM

        Hello, is there anyway of getting the data collected in the job sheets into the CRM. We are collecting inspection data which we were using zoho forms for but the job sheets in fsm seem like a lot better way to collect it but we need to be able to get
      • Bookmark order

        Hi all, We have a very big document/template that requires manual editing after doing a mail merge. To make this easier, I thought I would add bookmarks to navigate to the areas that will require editing. I thought these would be in order that they appear
      • Zoho Bookings API, timezone is not recognized when passed

        Has something changed? Time zone is being passed through API but it is NOT being recognized. response is not showing time zonetime that was passed through request. This is an URGENT issue as it is preventing bookings! Seems like this is due to a recent
      • Voicemail to Text Transcription

        Hello, We use the Twilio phone integration in Zoho Desk. When a voicemail is left, it creates a Ticket in Zoho Desk, and we are able to listen to the audio recording in the Ticket. My hope is to also have a voicemail-to-text transcription show up in the
      • Please don't remove the option to modify tax.

        Hi, I saw that the option to customize tax will be removed. This is VERY PROBLEMATIC for US companies who ship to different states because each zip code in the USA has its own tax rate for a single product. This is an awful idea. Please don't take this away.
      • Workflow to update the field "Deposit To" in Sales Receipt/Invoice

        After an invoice/sales receipt is created, I can't find a way to create a workflow that would update the field "Deposit To". Apparently, some other fields are visible in the workflow, but not the "Deposit To". Any insight?
      • payment gateway disabling in my ecommerce store

        hi i have disabled my payment gateway paytm from my website soigne from the backend but it is showing in my front end part when someone orders my products i want to remove it completelty so that it does not show in the front end part plz give me a suitable
      • Record GST Paid for Imported Goods

        In Australia, goods that imported from overseas needs to pay GST per invocied value. In most case, the freight forwader (logistic agent) paid this on behalf of importer (us), and invoice us in together in their freight invocie.  How do we setup a proper
      • subscribe email list for offer and updates is not working for zoho commerce

        my subscribing to email list is not working for offers and updates for my ecommerce website soignee it is saying please wait can anyone tell me the reason for this
      • How to make Deal field required for "Standard" layout and hidden in "Customer Portal" Layout?

        How to make Deal field required in tge "Standard" layout and hidden in "Customer Portal" Layout?
      • Commerce service

        If I am selling a service in Commerce, how do I turn off shipping?
      • Widget JS SDK to Upload a photo to a record in a Module

        Good day,  I would really appreciate it if someone can assist me. I have written a widget, to be used in a Custom Module in CRM.  My goal: I want to upload a photo from my computer and display it in die "upload image" field. I am using the JS SDK: https://help.zwidgets.com/help/v1.1/index.html
      • how do i see a list of active End Users?

        looking for a list of who i sent invitations to be an End User?  who has signed up? 
      • Email template for customer notification on ticket reply is not being used

        I've set up an email template for notify contact up upon receiving a reply in ticket. When I send a reply to the ticket, it is not using that email template. It just sends a normal looking email. How do I make it so that the email template is being used?
      • Conversation to Resolution

        Good day, I'd like to know how others are doing it. When we close a ticket, we reply to the ticket via email with photos of the issue and disclaimers. Then, we enter (copy and paste) the exact text in the resolution for reporting. I asked Zogo for a possible
      • Zoho Sign & Analytics

        Hi, Is it possible to import data from Sign into Analytics?
      • Zoho Desk - Feature Request - Add more social channels on Community user profile

        Hi Team, While updating my profile here I noticed that it is only possible to add Facebook and Twitter social links. 1. Please consider adding at least LinkedIn and if possible, other popular channels. 2. Please consider renaming Twitter field name to
      • Train Zia answer bot on only part of Knowledge Base?

        We are trialing Zia answer bot and hope to use it on the knowledge base to help our users find the information they are looking for. I have found how to train Zia on the entirety of our knowledge base. But is there a way to train it on only certain categories
      • More Workflow Triggers

        We utilize a lot of workflows in our organization. Recently we've identified two use cases where we would like a workflow to run a function. Upon further checking, the workflow trigger wasn't available, or the only option was to run the workflow more
      • Modular cannot Edit in portals

        I have a custom module in CRM. If I create in either CRM or portals, I can edit it in the CRM but I can't edit in the portal. Even if it is created in the portal it wont edit. Anyone know why? I've created a new module and it works fine but this one
      • ViewID and Zoho Desk API

        I'm looking at the documentation for Listing contacts and it looks like you can filter by ViewID. I assume this is views created in a department or all departments. Is this correct? And if so, how do I find the ViewID for that view? EDIT: I see the view
      • Writing on sketch cards is bugged when zoomed in

        When zoomed in, it writes a noticeable distance above or to the side of where you're actually trying to write. The further you're zoomed in, the more noticeable it is. Zooming is also entirely absent on the desktop version.
      • Lost the ability to sort by ticket owner

        Hi all, in the last week or so, we have lost the ability to sort tickets by Ticket Owner. Unlike the other columns which we can hover over and click on to sort, Ticket Owner is no longer clickable. Is it just us, or are other customers seeing this too?
      • In Zoho CRM, is it possible to transition from Approach 1 to Approach 3 based on the contract End Date? automatically

        In Zoho CRM, is it possible to transition from Approach 1 to Approach 3 based on the contract End Date? I have one issue between Approach 1 to Approach 3 there is another transition Approach 2 Iam faceing the issue if use the blue print API means i able
      • Introducing Rollup summary in Zoho CRM

        ------------------------------------------Moderated on 5th July'23---------------------------------------------- Rollup summary is now available for all organizations in all the DCs. Hello All, We hope you're well! We're here with an exciting update that
      • Introducing Color and Order Preferences for Blueprint Transitions

        Blueprints exist to improve the efficiency of your company's processes and ensure compliance — but only if your users follow them promptly. More often than not, your users may find it challenging to adopt your processes and follow through on them, especially
      • HOW CAN I ADD NOTE FIELD IN EMAIL TEMPLATE?

        I have an email template which i use as a lost deal notification. I would like to mention "Note" field also which captures the reason for the lost deal. I am not able to do so and i checked with help desk and they confirmed that it is not possible. Is
      • Announcing Early Access to "Zoho CRM for Everyone" — A new and exciting update to Zoho CRM

        We are delighted to announce an Early Access to Zoho CRM for Everyone— a truly democratic approach to managing a CRM, gift-wrapped in an exciting and intuitive user interface. Here, multiple teams across an organization can coordinate among each other
      • Subject: Urgent: Unrelated Email Automation Issue – Request for Immediate Resolution

        Dear Zoho One Support Team, We are currently facing a critical issue with email automation in our Zoho One account. Despite deleting the associated templates and workflows, the same email templates are still being sent to our customers. This has become
      • Next Page