Leveraging NuxtJS to develop custom widgets for Zoho CRM

Zoho CRM offers Widgets as a way to enhance its functionality. By utilizing the widgets feature, users can seamlessly embed UI components within their CRM and leverage data from third-party applications to execute actions based on specific requirements.

Essentially, a widget is an HTML file that gets loaded in a popup when a custom button is triggered. To interact with Zoho CRM's data, it is necessary to load jQuery and their JS SDK within the HTML file.

The basic structure of an HTML file for a widget typically resembles the following:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
    <script src="https://live.zwidgets.com/js-sdk/1.0.5/ZohoEmbededAppSDK.min.js"></script>
    <title>Document</title>
  </head>
  <body>

    <script>
      ZOHO.embeddedApp.on("PageLoad",function(data) {
        console.log(data);
        //Implement Custom Business Logic here
      });

      ZOHO.embeddedApp.init();
    </script>
  </body>
</html>

Within this file, the line console.log(data) will output details regarding the page where the widget is activated. For instance, if it's a Lead page, it will display information related to that particular lead, such as the ID.

To manage data storage/retrieval, one must integrate functions within the section marked

//Custom Business logic goes here
.

An example code snippet for fetching all Leads through this widget would appear as follows:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
    <script src="https://live.zwidgets.com/js-sdk/1.0.5/ZohoEmbededAppSDK.min.js"></script>
    <title>Document</title>
  </head>
  <body>

    <script>
      ZOHO.embeddedApp.on("PageLoad",function(data) {
        ZOHO.CRM.API.getAllRecords({Entity:"Leads"})
          .then(function(data){
            console.log(data)
          })
      });

      ZOHO.embeddedApp.init();
    </script>
  </body>
</html>

As I needed to develop multiple Zoho Widgets while reusing the same Vue Components across each Widget, I contemplated using NuxtJS. Although I successfully created the Vue Components, I am unsure about integrating Zoho's JS SDK.

If anyone has any recommendations or tips on how to resolve this issue, your assistance would be greatly appreciated! Thank you!

Answer №1

Is it possible to store the SDK function in a separate file outside of your HTML document, where you can easily access all the methods from the SDK API?

You can simply import your SDK into the header section of your HTML file.

Answer №2

After some searching, I came across a solution on the GitHub issues page that actually did the trick. Hopefully, this will be helpful to you as well.

When it comes to defining your script under data, you can input it as a string like this:

<template>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div v-html="scripts"></div>
</template>
<script>
export default {
  data: () => ({
    scripts: "<script src='https://www.google.com/recaptcha/api.js'><\/script>"
  })
}
</script>

Simply add a div tag in your page with v-html="script" and give it a try – it worked smoothly for me. Despite its effectiveness, I can't help but think there might be a better approach out there. Nonetheless, I hope this proves beneficial to you too.

You can find more details and ongoing discussions on the issue at GitHub: https://github.com/nuxt/nuxt.js/issues/2000

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transform URLs to end with .jpg using NextJS

My API has a specific endpoint called /api/thumbnail that currently returns a JPEG image. However, I would like the endpoint to also accept .jpg, so it can be accessed as /api/thumbnail.jpg. Would I be able to achieve this using only pure NextJS code, or ...

Tips on adding line breaks after periods that are not at the end of a sentence in HTML text nodes with regular expressions

Looking to craft a regex that can identify all periods not enclosed in quotes and not followed by a '<'. This is for the purpose of converting text into ssml (Speech Synthesis Markup Language). The regex will be utilized to automatically inse ...

Unable to find any interactive elements on the page

When I visit this website, I come across a chart. I am able to locate the chart boundaries element using //div[@data-chart_id='product_cannabinoids'], but I cannot find the rect, svg, or g elements inside it. Even though I can see these eleme ...

Having trouble getting JavaScript to work with the link_to Delete in Rails 4.1.8?

I'm currently working through the introductory Rails guide found at One issue I've encountered involves using the link_to method to delete an article. Despite following the instructions in section 5.13 of the guide, the server console indicates ...

Storing the token in cookies for Laravel / Vue Passport (SPA) implementation

I've been following a Vue + Laravel authentication tutorial and I've got everything set up. However, the tutorial then delved into storing tokens in local storage, which is not considered best practice due to its susceptibility to XSS attacks. T ...

Making all requests server-side in Next.JS: A step-by-step guide

I am in the process of creating a Next.JS application that will be retrieving data from both a Python API and a Postgres Database. Although this task may seem straightforward, the project requirements dictate that all requests must originate from the serv ...

Using JSON Object for Default Selection in an Angular Dropdown Menu

Here is some code I have that fills in a specific select item on a webpage: <select ng-model="activity.selectedParent" ng-options="parent as parent.title for parent in parents track by parent._id"></select><br> I'm curious if there ...

Failed to create WASM module: "module does not exist as an object or function"

I'm attempting to initialize a .wasm file locally within node.js in order to execute the binary on my local machine and mimic the functionalities of a webpage. Below is a simplified version of my setup: const fetch = require("node-fetch"); const impo ...

Error: Exceeded Maximum Re-Renders. React has set a limit on the number of renders to avoid infinite loops. Issue found in the Toggle Component of Next.js

I am struggling with setting a component to only display when the user wants to edit the content of an entry, and encountering an error mentioned in the title. To achieve this, I have utilized setState to manage a boolean using toggle and setToggle, then ...

Adjust the size of the text and the textarea at the same time

I am trying to resize text simultaneously while resizing the textarea in my code. I am using jQuery for this functionality. However, I believe there is an issue with the click function being separated. Any advice on how to fix this would be greatly appreci ...

Can we incorporate modal images into the design?

Can modal images be incorporated into a blog post? If necessary, I'm utilizing the Vimux/Mainroad theme. ...

AngularJS is throwing an error because the term "grunt" has not

Today is the day I embark on my journey with Grunt for testing my JavaScript code. All the necessary grunt modules have been successfully installed and are documented in a json file called package.json. { "name": "LarissaCity", "private": true, ...

Changing a div's properties is causing jQuery to behave strangely

Something strange happened while coding in javascript, especially with some jquery functions. Check out my code below <?php // Encoded in UTF-8 if(isset($_SESSION['username'])) { ?> <script type="text/javascript"> funct ...

Is it feasible to utilize an array of properties with the "item-text" attribute in Vuetify?

<v-autocomplete v-model="friends" :disabled="isUpdating" :items="people" label="Select" item-text="name" <!-- Array ['name', 'id', 'value'] can be used her ...

Tips for transferring data between various C# and JavaScript applications

On my ascx page, there is a div element that triggers a JavaScript function when clicked and sends an integer value. //HTML <div style="float: right; margin-right: 150px;" class="innerDivStyle" onclick="userStartExtend(2)"> < ...

Dealing with JS and Spring issues

I created a simple script that retrieves longitude and latitude values and populates an input form. Here is the HTML: <p id="demo">Click the button to get your coordinates:</p> <button onclick="getLocation()">Try It</button> <sc ...

Illustrate a sphere within the canvas

I successfully declared the next square, however now I am eager to accomplish the same for a circle... Could you please provide guidance on how to achieve this? Thank you. //Create Variable var circ = new Circle(320, 380, 50); //Define the circle functi ...

Incorporate a server-side stored JavaScript document into an HTML file (using Node.js)

Running into a slight snag with my latest project. Using node and express to create a simple webpage, everything is rendering just fine except for the javascript file (test.js) not being delivered to the user. <!doctype html> <html> < ...

Fixing a div at the top post scroll - bug on iOS mobile device

I am looking to achieve a similar effect as demonstrated in the example below: https://css-tricks.com/scroll-fix-content/ Essentially, the goal is to have a div become fixed at the top of the page after scrolling to a certain point. Initially, the div wil ...

Scroll up and down to witness the enchanting interplay of fading in and out

Looking to expand upon the solution given in this response. The existing code effectively fades in an element while scrolling down and fades out an image when scrolling up; however, it lacks the functionality to fade out when scrolling down. I am aiming ...