Tip 33: How to create custom forms and reports using widgets

Tip 33: How to create custom forms and reports using widgets


Hi folks,

In this month's tip, we're going to talk about how to use widgets to create custom forms and reports in your Creator application.

But, before that, let's cover a few basics.

What are widgets? 

Widgets help you extend the capabilities of your apps and perform tasks beyond the scope of built-in features. You can create powerful apps with richer user experiences and redefine the way your application interacts with your customers. For example, you can build and embed interactive UI components, such as image sliders and multistep forms. You can make use of HTML, CSS, or JavaScript libraries and reusable UI components to create an interactive interface.

How can you create a custom widget?

We've already shared a sample widget in our help article to integrate with Creator. The widget can be integrated with Creator forms and reports only by specifying the component link name and values in a JSON structure. 

In this tip, we'll walk you through how to create a widget with a custom design for forms and tables (reports). To create it, we'll use HTML, CSS, and JavaScript that we'll integrate into the Creator database using our JS API.

Let's create the Zoho Creator widget!

To create the Zoho Creator widget, you must install the Command Line Interface (CLI) on your machine. You can refer to this help article to install the CLI and create your widget with the help of this document.

Note: The CLI is used to send commands to a software program as lines of text, in order to interact with it. This interaction includes typing commands into the interface and receiving responses for them. 

Methods used to Creator custom widgets

HTML & CSS - Here, we'll leverage HTML and CSS to design custom forms and reports (tables).

JavaScript - With Javascript, we'll be able to implement show/hide components along with data-oriented backend functionality. For example, we can pass data from an HTML table to a custom form within the widget.

JS API - We'll use this to push, pull, delete, and update data to Zoho Creator.

Using the above four methods, let's see how we can create a custom form and table to add and view the data we enter into the application.

We'll be following the below steps to design the custom form and report:

1. Design the custom contact form using HTML and CSS code.

2. Use JavaScript code to show the form when a user clicks on the + button.

3. Use the JS API to add data to the Creator database, once the user enters data in the fields. Then, we'll use JavaScript again to refresh the form once the data is added to the Creator database.

4. Create the custom table (report) using HTML.

5. Use CSS to add style to your table, like colours, font properties, text alignments, etc.

6. Use JavaScript code to show and refresh the table.


So let's get started !

Step 1: Design the custom contact form using HTML and CSS code.




HTML code

<body>
 <div class="wrapper" >
         <div class="icon addIcon"onclick="myftn()" >
            <div class="tooltip">
              <b> Add&nbsp;Data</b>
            </div>
            <span><i class="fa fa-plus"></i></span>
         </div>
      </div>
    <div class="contact-form"id="myForm">
        <img alt=""class="avatar"src="https://i.postimg.cc/zDyt7KCv/a1.jpg">
        <b><h2>Contact Form</h2></b>
        <form id="itsMyForm">
            <p>Name</p><input type="text"id="EnterName"name="EnterName"placeholder="Enter Your Full Name">
            <p>Email</p><input type="text"id="EnterEmail"name="EnterEmail"placeholder="Enter Your Email">
            <p>Age</p><input type="number"id="EnterAge"name="EnterAge"placeholder="Enter Your Age">
            <p>Mobile</p><input type="text"id="EnterMobile"name="EnterMobile"placeholder="Enter Your Mobile Number">
            <button class="Submitbutton"id="SubmitReset"type="button">S U B M I T</button><br><br><br>
<button class="Resetbutton"id="SubmitReset1"type="button"onclick="resetForm()">R E S E T</button>
        </form>
    </div>
</body>


CSS styling code

<style>
.wrapper{
  display: inline-flex;
}
.wrapper .icon{
  margin: 0 20px;
  text-align: center;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: relative;
    right:-900px;
  top:70px;
  z-index: 2;
  transition: 0.4scubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.wrapper .icon span{
  display: block;
  height: 60px;
  width: 60px;
  background: #fff;
  border-radius: 40%;
  position: relative;
  z-index: 2;
  box-shadow: 0px 10px 10pxrgba(0,0,0,0.1);
  transition: 0.4scubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.wrapper .icon span i{
  line-height: 60px;
  font-size: 25px;
}
.wrapper .icon .tooltip{
  position: absolute;
  top: 0;
  z-index: 1;
  background: #fff;
  color: #fff;
  padding: 10px 18px;
  font-size: 20px;
  font-weight: 500;
border-radius: 25px;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0px 10px 10pxrgba(0,0,0,0.1);
  transition: 0.4scubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.wrapper .icon:hover .tooltip{
  top: -70px;
  opacity: 1;
  pointer-events: auto;
}
.icon .tooltip:before{
font-family: Arial, Helvetica, sans-serif;
  position: absolute;
  content: "";
  height: 15px;
  width: 15px;
  background: #fff;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%) rotate(45deg);
  transition: 0.4scubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.wrapper .icon:hover span{
  color: #fff;
}
.wrapper .icon:hover span,
.wrapper .icon:hover .tooltip{
font-family: Arial, Helvetica, sans-serif;
  text-shadow: 0px -1px 0pxrgba(0,0,0,0.4);
}
.wrapper .addIcon:hover span,
.wrapper .addIcon:hover .tooltip,
.wrapper .addIcon:hover .tooltip:before{
  background: #ffc475;
}
.wrapper .ViewIcon:hover span,
.wrapper .ViewIcon:hover .tooltip,
.wrapper .ViewIcon:hover .tooltip:before{
background: #ffc475;
}
body {
    content: '';
    position: fixed;
    width: 100vw;
    height: 100vh;
background-image: url(https://images.unsplash.com/photo-1515420043797-69a1bc7ee7a0?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8MTU0fHx8ZW58MHx8fHw%3D&auto=format&fit=crop&w=800&q=60);
    background-position: centercenter;
    background-repeat: no-repeat;
    background-attachment: fixed;
    -webkit-background-size: cover;
    background-size: cover;
}
.contact-form {
font-family: Arial, Helvetica, sans-serif;
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 400px;
    padding: 80px 40px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
}
.avatar {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    top: calc(-80px/2);
    left: 190px;
}
.contact-form h2 {
    margin: 0;
    padding: 0 0 20px;
    color: #fff;
    text-align: center;
    text-transform: uppercase;
}
.contact-form p {
    margin: 0;
    padding: 0;
    font-weight: bold;
    color: #fff;
}
.contact-form input {
    width: 100%;
    margin-bottom: 20px;
}
.contact-form button {
    width: 40%;
}
.contact-form input[type=email], .contact-form input[type=password],.contact-form input[type=text],.contact-form input[type=number],.contact-form input[type=radio] {
    border: none;
    border-bottom: 1pxsolid #fff;
    background: transparent;
    outline: none;
    height: 40px;
    color: #ffc475;
  font-size: 16px;
}
.Submitbutton {
    height: 35px;
    color: white; font-size: 15px;
  background: none; cursor: pointer; border-radius: 5px; border: none;  outline: none; position: absolute; right:250px; bottom:40px;}  Submitbutton:hover { background: #ffc475;  color:black;both} .Resetbutton { height: 35px; color: white; font-size: 15px; background: none; cursor: pointer; border-radius: 5px; border: none; outline: none; position: absolute; left:250px; bottom:40px;}.Resetbutton:hover { background: #ffc475;        color:black;}.contact-form a { color: #ffc475; font-size: 14px; font-weight: bold; text-decoration: none;}
</style>

Step 2: Use the JavaScript code to show the form on click of the + button.

<script>
function myftn()
{
        document.getElementById("customers").style.display = "none";
        document.getElementById("myForm").style.display = "block";
    }
</script>

Step 3: Use the JS API to add data to the Creator DB once the user enters data in the fields. Then, we'll use JavaScript again to refresh the form once the data is added to the Creator database.

  <script>
function myfunctionAdd(){
                           ZOHO.CREATOR.init()
                           .then(function(data) {
                                                           //Code goes here
                          var Namee= document.getElementById("EnterName").value;
                          var Emaill= document.getElementById("EnterEmail").value;
                          var Mobilee= document.getElementById("EnterMobile").value;
                          var Agee= document.getElementById("EnterAge").value;
                                                               formData = {
                                                               "data" : {"Name":Namee,"Email" : Emaill, "Phone_Number":Mobilee, "Age":Agee} }
       var config = {
       formName : "Add_Request_Form",
       data : formData
       }                                                         
      ZOHO.CREATOR.API.addRecord(config).then(function(response){                                                           
        if(response.code == 3000){                                                               
        console.log("Record added successfully");
        }
       });
       //get all records API
       });
       }
function resetForm(){
       setTimeout(function(){document.getElementById("itsMyForm").reset(); }, 1000);
   }
   var buttonbtn = document.getElementById("SubmitReset");
     buttonbtn.addEventListener("click", myfunctionAdd);
    buttonbtn.addEventListener("click", resetForm);
   function resetForm(){
      setTimeout(function(){document.getElementById("itsMyForm").reset(); }, 1000);
   }
</script>

Step 4: Create the custom table (report) using HTML, as shown in the image below.




<body>
   <div class="icon ViewIcon" onclick="showtable()" id="myBtn" >
            <div class="tooltip">
              <b> View&nbsp;Data</b>
            </div>
            <span><i class="fab fa-wpforms"></i></span>
         </div>
<table id="customers">
       <tr>
         <th>&nbsp;&nbsp;P E R S O N&nbsp;&nbsp;N A M E&nbsp;&nbsp;</th>
         <th>&nbsp;&nbsp;P H O N E&nbsp;&nbsp;N U M B E R&nbsp;&nbsp;</th>
         <th>&nbsp;&nbsp;E M A I L&nbsp;&nbsp;A D D R E S S&nbsp;&nbsp;</th>
         <th>&nbsp;&nbsp;A G E&nbsp;&nbsp;</th>
         <th>&nbsp;&nbsp;ID&nbsp;&nbsp;</th>
         <th>&nbsp;&nbsp;D E L E T E&nbsp;&nbsp;</th>
         <th>&nbsp;&nbsp;E D I T&nbsp;&nbsp;</th>
       </tr>
     </table>
    <div class="removeBtn"id="DeleteButtonn" >
          <div onclick="DeleteDataa(this)" >
             <div>
             </div>
                   <span><i class="fas fa-trash-alt"></i></span>
          </div>
          </div>
     <div class="editBtn"id="EditButton" >
          <div onclick="EditDataa(this)" >
             <div>
             </div>
                   <span><i class="fas fa-edit"></i></span>
          </div>
          </div>
</body>

Step 5: Use CSS to add style to your table, like colors, font properties, text alignments, etc.

<style>
#customers {
display:none;
 font-family: Arial, Helvetica, sans-serif;
   border-collapse: collapse;
   width: 91%;
  background: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
   position: absolute;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
border-collapse: separate; border-spacing: 0;
 }
 #customers td, #customers th {
 border: 1pxsolid ;
   padding: 8px;
     color: #ffc475;
    border-radius: 15px;
       text-align:center;
 }
#customers tr:nth-child(even){background-color: ;
    border-radius: 15px;
}
 #customers tr:hover {background-color:black;
    border-radius: 15px;
    cursor:pointer;

}
 #customers th {
 padding-top: 12px;
   padding-bottom: 12px;
   text-align: left;
   background-color:Black;
   color: #ffc475;
   text-align:center;
   border-radius: 15px;
 }
#customers td {
    border: solid 1px #000;
    border-style: nonesolidsolidnone;
}
#customers tr:first-child td:first-child { border-top-left-radius: 15px; }
#customers tr:first-child td:last-child { border-top-right-radius: 15px; }
#customers tr:last-child td:first-child { border-bottom-left-radius: 15px; }
#customers tr:last-child td:last-child { border-bottom-right-radius: 15px; }
#customers tr:first-child td { border-top-style: solid; }
#customers tr td:first-child { border-left-style: solid;
</style>

Step 6: Use the JavaScript below to show and refresh the table.

<script>
function showtable(){
       document.getElementById("myForm").style.display = "none";
   document.getElementById("customers").style.display = "block";
     }
     function myfunction()
     {
     var rowCount = customers.rows.length;
                         for (var i = rowCount - 1; i > 0; i--) {
                             customers.deleteRow(i);
                         }
                  var array1 = [];
                  ZOHO.CREATOR.init()
                  .then(function(data) {
                    //Code goes here
                    var config = {
              reportName : "All_Requests",
              criteria: "(ID!=0)",
              page : 1,
              pageSize : 10
          }
          ZOHO.CREATOR.API.getAllRecords(config).then(function(response){
              //callback block
              var a=0;
              var roww = 1;
              var recordArr = response.data;
              for(var index in recordArr){
                  var rec=(recordArr[index]);
                  var val1=rec["Name"];
                  var val2=rec["Phone_Number"];
                  var val3=rec["Email"];
                  var val4=rec["Age"];
                  var val5=rec["ID"];
                  var display=document.getElementById("customers");
                  var newRow=display.insertRow(roww);
                  var cell1 =newRow.insertCell(0);
                  var cell2 =newRow.insertCell(1);
                  var cell3 =newRow.insertCell(2);
                  var cell4 =newRow.insertCell(3);
                  var cell5 =newRow.insertCell(4);
                  var cell6 =newRow.insertCell(5);
                  var cell7 =newRow.insertCell(6);
                  cell1.innerHTML = val1 ;
                  cell2.innerHTML = val2 ;
                  cell3.innerHTML = val3 ;
                  cell4.innerHTML = val4 ;
                  cell5.innerHTML = val5 ;
                  var div = document.getElementById("DeleteButtonn");
                  cell6.innerHTML = div.innerHTML;
                var div = document.getElementById("EditButton");
               cell7.innerHTML = div.innerHTML;
              a=a+1;
              roww=roww+1;
          }
          });
          });
     }        
     // Selecting button element
   var btn = document.getElementById("myBtn");
    btn.addEventListener("click", showtable);
   btn.addEventListener("click", myfunction);
</script>

Note : We've attached a custom widget file that contains the below JS API tasks. This will help you create your own custom widgets and perform the following actions:

  • Add Record
  • View All Records
  • Update Record
  • Delete Record

To use the attached widget in your application for testing, all you need to do is replace the form link name, report link name, and all the field link names with yours in the JS API call.

Wouldn't it be useful to create a custom form and report like this? If you have any questions regarding this tip, please feel free to add them as comments below. We'd be happy to answer them for you !

Stay Safe and Good Day :)
    • Recent Topics

    • Sync custom module ID to Lead module

      Hello, I am trying to sync Contract ID (custom module) from Deal module. I have an existing function that whenever a contract is created, it will automatically creating deals based on the frequency of the contract. Now i am having problem to show the
    • In Kiosk, please support "File upload field" in the "Field Update" action

      Hello. Supporting "File upload field" in the "Field Update" actions would be a great addition to Kiosk Studio. I would appreciate it if you could evaluate it. Saludos,
    • can I link a contacts to multiple accounts

      can I link a contacts to multiple accounts
    • Change Last Name to not required in Leads

      I would like to upload 500 target companies as leads but I don't yet have contact people for them. Can you enable the option for me to turn this requirement off to need a Second Name? Moderation update (10-Jun-23): As we explore potential solutions for
    • For security reasons your account has been blocked as you have exceeded the maximum number of requests per minute that can originate from one account.

      Hello Zoho Even if we open 10-15 windows in still we are getting our accounts locked with error " For security reasons your account has been blocked as you have exceeded the maximum number of requests per minute that can originate from one account. "
    • Zoho Creator - Zoho Analytics

      I am facing an issue in Zoho Analytics where I am still seeing deleted data from the Zoho Creator form I created. Could you please look into this and let me know what needs to be done?
    • The Social Wall: November 2024

      Hey everyone, As we move into December, we're excited to share all the updates that went live in Social during November. View, monitor, and respond to your WhatsApp and Telegram messages from Inbox Take your communication a step further by integrating
    • Launching CPQ for Zoho CRM! An in-built solution for bespoke quote management

      Hello everyone, We are thrilled to announce the public release of CPQ (Configure, Price, Quote) for Zoho CRM, which is a fundamental block in sales management. NOTE: CPQ was a public early access feature from March 2023 — January 2024. Since February
    • Add an action to set agent as a member of a team in zoho desk

      Hi, Please add an action to zoho flow to set agent as a member of a team in zoho desk (add to a team or remove from a team). Regards, Ram
    • Power of Automation :: Automatically set the dependency between Parent task and the respective sub tasks

      A custom function is a software code that can be used to automate a process and this allows you to automate a notification, call a webhook, or perform logic immediately after a workflow rule is triggered. This feature helps to automate complex tasks and
    • Registration in community

      Namaste I am from Shimla, But there is no option selection of shimla.
    • Spell Check default language

      Hello All, Is it possible to set the Spell Check default language? I can't find it in the settings. Thanks a lot! Levente
    • Function #4: Schedule Customer Statements

      Regularly sending statements to customers is an imperative part of many business processes as it helps foster strong customer relationships and provides timely guidance on payments. While you can generate the statement of accounts and have it sent over
    • Music files on Zoho Docs

      1) Uploaded a ma3 music file from Itunes.  When I click on the link, i go to the page and see a music player but it doesn't play.  Clicking on the play arrow does nothing.  How to fix???? 2) Also, when i put up a .zip file  and goto the page, anyone download it.  That's fine. But with a music file, all I get is that non functional player with no way to simply download the song. Do I have to zip every song so it can be downloaded?
    • 5名限定 課題解決型ワークショップイベント Zoho ワークアウト開催のお知らせ (12/19)

      ユーザーの皆さま、こんにちは。Zoho ユーザーコミュニティチームの藤澤です。 12月開催のZoho ワークアウトについてお知らせします。 参加登録はこちら: https://us02web.zoom.us/meeting/register/tZAqdOCrrDMtGdL3w__UraUPaZxJpeS_wcyt ━━━━━━━━━━━━━━━━━━━━━━━━ Zoho ワークアウトとは? Zoho ユーザー同士で交流しながら、サービスに関する疑問や不明点の解消を目的とした「Zoho ワークアウト」を開催します。
    • Restrict Employees Access to Zoho Support

      Dear Zoho Support Team, Greetings! I am the focal point for all Zoho-related matters in our organization, and I would like to request the following features to help us streamline and centralize our support interactions. We request that zoho one support
    • How to import timesheets or entries into a projecgt

      How can one import timesheets into a project via a csv file?
    • Automatic License Management Upon User Deactivation in Zoho One

      Dear Zoho Team, We would like to propose a feature enhancement for Zoho One regarding license management. Currently, when a user is deactivated, their license is not automatically downgraded or removed from our account. Zoho explains this behavior by
    • Shared Snippets Everyone

      Hi, Now that the Shared Snippets have been released and I think will be the most used feature implemented in 2023 :) Creating and Using Snippets in Ticket Responses - Online Help | Zoho Desk Maintain consistency in ticket responses with shared snippets
    • Introducing parent-child ticketing in Zoho Desk [Early access]

      Hello Zoho Desk users! We have introduced the parent-child ticketing system to help customer service teams ensure efficient resolution of issues involving multiple, related tickets. You can now combine repetitive and interconnected tickets into parent-child
    • How to suppress display of "USD" of currency field?

    • When is Zoho Vault getting fuzzy search?

      Seeing posts on here dating back as far as 3 years complaining about Vaults search functionality. It’s terrible. Please include fuzzy search, and sorting of results according to “most applicable”; not just alphabetically.
    • Automation#22 Track Ticket Duration at Specific Status

      Hello Everyone! Welcome back to the Community Learning Series! Today, we explore how Zylker Techfix, a gadget servicing firm, boosted productivity by tracking the time spent at a particular ticket status in Zoho Desk. Zylker Techfix customized Zoho Desk’s
    • Self-Support Portal invites

      I'm a one man operation and I'm using the free version of the Zoho Desk for now, but I am in need of help. When I do test tickets, I get a reply from the system inviting me to join the Self Service portal. I don't plan on using that, so I wonder if there
    • Lookup field in User module cannot look up to custom modules!

      Hi there, Expense has been great so far but it's sad to see that a simple thing such as allowing a lookup to custom modules from the Users module is not yet implemented. Hope to see this in the next release. Do you have any plan for that?
    • Tip #10: Automatically add tags to Zoho CRM records using form responses

      You may be using tags to filter records, create reports based on specific tags, or let your sales team to know which clients to give priority to. Don't skip tagging for the crm records added via forms. The tags can be set to be automatically captured during the form submission. How it works When you set up a configuration to push form entries into CRM, you can add a tag to them automatically. The tag value can vary based on the respondent's input (captured using form fields), or you can include a
    • Understanding response time

      We have the following set up for our SLA. When a contact first writes in, the response due and resolution due dates are set. When one of our agents responses, the response due goes away. When a ticket gets a response from the contact, it appears to reset
    • Publish multiple languages at once in Knowledge Base

      Does anyone know if it is possible to publish multiple translated articles at the same time? My knowledge base has about 35 languages, and while I have them set up to automatically translate, I still have to go in and select each language and manually
    • Canvas and Related lists

      Hi, As much as I like canvas, when adding in a asection with related lists,it doesnt mimic the same functionality as the standard view within the CRM e.g left hand panel will show the module and total number of records. Is there a way of indicating this
    • Email address ZOHO suggestions in replying - how to delete unwanted suggestions?

      Hi, I have some "unwanted" email addresses suggestions by ZOHO, and made some mistakes by replying for some tickets already. How can I clear this in ZOHO directly, I deleted all web browser history and cookies . Did not help :/ Below example, where one
    • Copy Widget to another Dashboard

      I can see the option to clone a widget to the same dashboard but is it possible to copy it to another dashboard?
    • Subform edits don't appear in parent record timeline?

      Is it possible to have subform edits (like add row/delete row) appear in the Timeline for parent records? A user can edit a record, only edit the subform, and it doesn't appear in the timeline. Is there a workaround or way that we can show when a user
    • CRM x WorkDrive: File storage for new CRM signups is now powered by WorkDrive

      Availability Editions: All DCs: All Release plan: Released for new signups in all DCs. It will be enabled for existing users in a phased manner in the upcoming months. Help documentation: Documents in Zoho CRM Manage folders in Documents tab Manage files
    • Zoho Learn vs. Trainer Central

      Hi, I'm currently using Zoho One with a WordPress-based website and WooCommerce to manage my online courses. I would like to know what is the difference between Zoho Learn and Trainer Central and if it's possible for these two platforms to replace WP
    • How to Display a Logo Image on a Public Form?

      I would like to display a logo image in the header of a form. To achieve this, I added an Add Notes field to the form. The code below works perfectly for Zoho users accessing the form. However, when the form is made public, the image does not load properly:
    • Creating a Zoho Online Meeting in a Blueprint

      We are looking for an easy solution to schedule online meetings in a blueprint and ran into the same problem discussed in this topic: https://help.zoho.com/portal/en/community/topic/custom-function-to-set-meeting-to-online-meeting (After connecting Zoho
    • Enabling 'From Number' and 'To Number' fields in the Calls module

      Hello everyone, We've added "To Number" and "From Number" fields in the Calls module as part of our latest update to provide users with the option to enable or disable them through the Calls Preferences tab. When enabled, these fields will be displayed
    • Exciting Update: Multi WhatsApp Business Account (WABA) Support Now Available in SalesIQ!

      We’re pleased to share an important update that will enhance the way you manage your WhatsApp Business accounts (WABAs) within SalesIQ. With the launch of Multi WABA support, you can now connect and manage multiple brands more effectively, each under
    • Route Optimizer

      Does Zoho Inventory offer route optimization for our in-house deliveries? It will save us time to manually route our daily orders. Thank you
    • Can documents attached to different ZohoForms automatically go to different OneDrive folders?

      Hi there, I set a workflow to track and store applications coming in from our website. I created two different Zoho forms, one for unsolicited applications, one for applications to job postings. After any of the forms has been filled in, a new record
    • Next Page