Extension Pointers - JS SDK Series#7: Managing records, handling attachments, and adding notes from a widget

Extension Pointers - JS SDK Series#7: Managing records, handling attachments, and adding notes from a widget

Zoho CRM JS SDK supports APIs that help manage records, attach files, and add notes to a record, all from within the widget itself. The term record refers to the detailed information about an individual entity in the Zoho CRM module. Attachments and notes are additional information that add extra context to the record details for a variety of purposes, including sales, SLAs, proofs, etc. 

Let's first look at the syntax of each API followed by a working example demonstrating the purpose of the different APIs.

ZOHO.CRM.UI.Record
Syntax:

This API can help with multiple functionalities in managing records, such as:
ZOHO.CRM.UI.Record.create(data) - open CreatePage of the specified Record.
ZOHO.CRM.UI.Record.edit(data) - open EditPage of the specified Record.
ZOHO.CRM.UI.Record.open(data) - open DetailPage of the specified Record.

Here, data refers to the configuration object of 'object' type.

Configuration Object

Name
Type
Description
Entity
String
SysRefName of the module.
RecordID
String
The ID of the record to open or edit.
Target
String
Allowed values "_blank". To open the create/edit/open page of the record in a new tab.

ZOHO.CRM.API.attachFile

This API is used to attach files to a record in a module.

➤ The attachment will appear under the 'Attachments' related list section of the record.
➤ The maximum attachment limit for a record is 100MB.
➤ All attachment formats are supported except exe files.
➤ The API can be used in all modules that support the 'Attachments' section.

Syntax:

ZOHO.CRM.API.attachFile(config)

Here, config refers to the configuration object.

Configuration Object

Name
Type
Description
Entity
String
SysRefName of the module.
RecordID
String
The record ID for which the attachment is to be associated.
File
Object
File object to be attached.

The file object holds two properties.

Name
Type
Description
Name
String
The name of the file.
Content
Object
The file content.


ZOHO.CRM.API.addNotes

This API is used to add notes to a specific record in a module.

Syntax:

ZOHO.CRM.API.addNotes(config)

Here, config refers to the configuration object.

Configuration Object

Name
Type
Description
Entity
String
SysRefName of the module.
RecordID
String
The record ID for which the note is to be associated.
Title
String
The title for the note.
Content
String
The note content.

Consider a simple scenario where a user is running an ecommerce store using their Zoho CRM account. Their store offers a wide range of hardware and software products. There are also certain discount deals that are offered for several products in accordance with their sales strategy. Let's say that, after a good turnover, the user wants to delink a product from a certain discount deal. Besides delinking, the user would like to attach some of the relevant files and add notes to the deal in order to provide additional information on the reason for the delinking. The user would also like to view the full details of the product before delinking it from the deal. Let's see how all these features can be done from a widget.



Record.js code snippet:

Util={};
var EntityIds;
var EntityName;
var temp;

//Subscribe to the EmbeddedApp onPageLoad event before initializing the widget 
ZOHO.embeddedApp.on("PageLoad",function(data)
{
EntityIds=data.EntityId[0];
EntityName=data.Entity;

//Getting the product-related details of the deal using getRelatedRecords API
ZOHO.CRM.API.getRelatedRecords({Entity:EntityName,RecordID:EntityIds,RelatedList:"Products",page:1,per_page:200})
.then(function(data){
temp=data;
rec=data.data;
console.log(data);
$('#prodidlist').empty();

//Looping through the products
for (i = 0; i < rec.length; i++) 
{

/*populating the prodidlist list with the product names of all the products associated with the deal*/
prodid=rec[i].id;
prodname=rec[i].Product_Name;
var prodidlist = document.getElementById("prodidlist");
var option = document.createElement("OPTION");
option.innerHTML = prodname;
option.value = prodid;
prodidlist.appendChild(option);
}

})  

/*Viewing the complete details page of the selected product from the prodidlist using the record open API*/
Util.view=function()
{
ZOHO.CRM.UI.Record.open({Entity:"Products",RecordID:document.getElementById("prodidlist").value,Target:"_blank"})
.then(function(data){
console.log(data)
})
}  

Util.delink=function()
{

//Delinking the product selected from the product list and thereby dissociating it from the deal 
ZOHO.CRM.API.delinkRelatedRecord({Entity:EntityName,RecordID:EntityIds,RelatedList:"Products",RelatedRecordID:document.getElementById("prodidlist").value})
.then(function(data){
console.log(data)
})
var filesToLoad = document.getElementById("fileInputTag").files;
var filename=filesToLoad[0].name;
if(filesToLoad)
{
var file = filesToLoad[0];
ZOHO.CRM.API.attachFile({Entity:EntityName,RecordID:EntityIds,File:{Name:filename,Content:file}})
.then(function(data){
console.log(data);
});
}

// Adding the input value provided as a note to be associated with the deal  
ZOHO.CRM.API.addNotes({Entity:EntityName,RecordID:EntityIds,Title:"Delink Notes",Content:document.getElementById("notes").value}).then(function(datas){
console.log(datas);
});  

ZOHO.CRM.UI.Popup.close()
.then(function(data){
console.log(data)
})
}; 
})

  1. In the above code snippet, the entity ID and entity name are fetched on page load.
  2. The retrieved ID and entity name are then passed to the 'getRelatedRecords' API to fetch the complete 'Products' related list details of the specific deal.
  3. The products associated with the deal are then populated into a select list so the user can choose the product they would like to delink.
  4. The ZOHO.CRM.UI.Record.open API is used with the target property set to "_blank" to open the detail page of the chosen product. This displays the complete details of the product in a new tab upon clicking the 'View product details' button in the widget.
  5. Finally, upon clicking the 'Delink' button, three functions occur. Namely:
  • The chosen product is delinked from the associated deal.
  • The attachment file chosen is attached and will be available in the 'Attachments' section of the record using the ZOHO.CRM.API.attachFile API.
  • The notes provided by the user will be added to the notes section using the ZOHO.CRM.API.addNotes API.


The product is now delinked from the deal. The attachment is added under the 'Attachments' section, and the note is added under the 'Notes' section.



As stated in the above scenario, the user can choose the product they want to delink, attach a document, and add a note that is relevant to the delinking process, all from within a widget.

There are multiple APIs in the Zoho CRM JS SDK that serve and help to build extensions efficiently. Please refer to our JS SDK series for posts on other API functionalities and keep track of this space for more information.


SEE ALSO



    Access your files securely from anywhere







                            Zoho Developer Community





                                                  Use cases

                                                  Make the most of Zoho Desk with the use cases.

                                                   
                                                    

                                                  eBooks

                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                   
                                                    

                                                  Videos

                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                   
                                                    

                                                  Webinar

                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                   
                                                    
                                                  • Desk Community Learning Series


                                                  • Meetups


                                                  • Ask the Experts


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner




                                                            • Sticky Posts

                                                            • Kaizen #197: Frequently Asked Questions on GraphQL APIs

                                                              🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
                                                            • Kaizen #198: Using Client Script for Custom Validation in Blueprint

                                                              Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
                                                            • Celebrating 200 posts of Kaizen! Share your ideas for the milestone post

                                                              Hello Developers, We launched the Kaizen series in 2019 to share helpful content to support your Zoho CRM development journey. Staying true to its spirit—Kaizen Series: Continuous Improvement for Developer Experience—we've shared everything from FAQs
                                                            • Kaizen #193: Creating different fields in Zoho CRM through API

                                                              🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
                                                            • Client Script | Update - Introducing Commands in Client Script!

                                                              Have you ever wished you could trigger Client Script from contexts other than just the supported pages and events? Have you ever wanted to leverage the advantage of Client Script at your finger tip? Discover the power of Client Script - Commands! Commands


                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner







                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources


                                                                                              Zoho Writer Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ






                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方




                                                                                                            • Recent Topics

                                                                                                            • Need Easy Way to Update Item Prices in Bulk

                                                                                                              Hello Everyone, In Zoho Books, updating selling prices is taking too much time. Right now we have to either edit items one by one or do Excel export/import. It will be very useful if Zoho gives a simple option to: Select multiple items and update prices
                                                                                                            • Please Make Zoho CRM Cadences Flexible: Allow Inserting and Reordering Follow-Up Steps

                                                                                                              Sales processes are not static. We test, learn, and adapt as customers respond differently than expected. Right now, Zoho Cadences do not support inserting a new step between existing follow-ups or changing the type of an existing primary step. If I realize
                                                                                                            • Vendor Signatures Needed for Purchase Orders

                                                                                                              Hello everyone, We have a unique requirement that necessitates that Vendors & Suppliers formally acknowledge our Purchase Orders upon receipt. I was hoping that there would be an option to do so in Zoho Books, but that does not appear to be the case.
                                                                                                            • Is there an API to "File a Ticket" in Desk

                                                                                                              Hi, Is there an API to "File a Ticket" in Desk to zoho projects?
                                                                                                            • Critical Issue: Tickets Opened for Zoho Support via the Zoho Help Portal Were Not Processed

                                                                                                              Hi everyone, We want to bring to your attention a serious issue we’ve experienced with the Zoho support Help Portal. For more than a week, tickets submitted directly via the Help Portal were not being handled at all. At the same time no alert was posted
                                                                                                            • Unarchive tickets

                                                                                                              How can I manually unarchive tickets?
                                                                                                            • Optimize your Knowledge Base for enhanced accessibility by adding alt tags for images

                                                                                                              Let's learn why alt tags are crucial for your articles. You can add alternative tags (alt tags) and alternative text (alt text) to the images you share on your community forums or when embedding them in articles. Alt tags refer to the HTML attribute,
                                                                                                            • report showing assignment type

                                                                                                              Hi, We've created a number of workflows to allow us to auto assign tickets to agents based on keywords and other criteria. I'm struggling to create a report that would show me what is the percentage of tickets that are assigned automatically via workflows
                                                                                                            • Time Entry Notifications

                                                                                                              Hi All - I have support staff who place notes of their work in the time entry section of Zoho Desk. Is there a specific workflow or setting I need to enable to have the ticket holder updated via email when an entry is saved?
                                                                                                            • How to report 'Response violation' OR 'Resolution violation'

                                                                                                              Hi, I want to report on SLA Violation Type. I grouped my tickets on this column. It seems I only get 'Response and Resolution Violation' or 'Not Violated'. The former seems to be given to a ticket if only the Response Time was violated. I would expect
                                                                                                            • Should I Use DMARC?

                                                                                                              When I configure Zoho Mail's DMARC settings, it's mandatory to fill in the RUA and RUF (Aggregate notification email address*, Forensic notification email address*) addresses. When we enter an email address in these fields, we receive reports from the
                                                                                                            • Power of Automation :: Quick way to associate your Projects with Zoho CRM

                                                                                                              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
                                                                                                            • Formula field with IF statement based on picklist field and string output to copy/paste in multi-line field via function

                                                                                                              Hello there, I am working on a formula field based on a 3-item picklist field (i.e. *empty value*, 'Progress payment', 'Letter of credit'). Depending on the picked item, the formula field shall give a specific multi-line string (say 'XXX' in case of 'Progress
                                                                                                            • Unable to retrieve Contact_Name field contents using Web API in javascript function

                                                                                                              Hello, I've added a field in the Purchase Order form to select and associate a Sales Order (Orden_de_venta, lookup field). I've also created a client script to complete some fields from the Sales Order (and the Quote), when the user specifies the related
                                                                                                            • Restricting contact creation

                                                                                                              Hi all! I am looking to use Zoho Desk in a part of the business that takes end user enquiries. These are generally single interactions, and not linked to an account name. As Desk is Account centric, has anyone designed a way to manage these incoming emails
                                                                                                            • Import Holiday Calendars

                                                                                                              HI Zoho Is there anyway of importing an online calendar like https://www.calendarlabs.com into the business hours calendars, to speed up setup of holiday calendars. Also could we also request a feature where you can specify a Holiday as hours, i.e it could be that the company is on a 1/2 day due to a holiday or when it is Eid in the UAE and they are only allowed to work restricted hours so we need the calendar to be flexible to allow for this. Regards Jamie
                                                                                                            • Filtering Tickets based on Email headers

                                                                                                              We're starting to get a lot more junk coming into our Zoho Desk, which is then triggering unnecessary email alerts to agents. Once thing we could do to cut this junk in half, is to filter tickets based on email headers. Any email containing the `List-Unsubscribe`
                                                                                                            • Zoho Books - France

                                                                                                              L’équipe de Zoho France reçoit régulièrement des questions sur la conformité de ses applications de finances (Zoho Books/ Zoho Invoice) pour le marché français. Voici quelques points pour clarifier la question : Zoho Books est un logiciel de comptabilité
                                                                                                            • Feature Request: Conditional Field Mandatoriness Based on Display Status

                                                                                                              Hello Zoho Creator Team, I would like to suggest an enhancement to improve the flexibility of form validations. Currently, when we need a field to be mandatory only if it's displayed on the form, the only option is to: Set the field as not mandatory in
                                                                                                            • Im Stuck in an EDIT ONLY WITH WIZARD issue

                                                                                                              So I found Wizards to be a really helpful tool in minimizing the exposure of redundant, superfluous fields to staff that would never otherwise have to edit those fields. My issue is, that when the record (in this case a lead) is created with a wizard,
                                                                                                            • Data Migration Strategies for Moving to a Cloud Solution

                                                                                                              Hi everyone, I’ve been working on moving some of our critical systems, including CRM and project data, to a Zoho cloud solution, and one of the biggest challenges I’ve encountered is data migration. Transferring large volumes of data while keeping it
                                                                                                            • Bulk Moving Images into Folders in the Library

                                                                                                              I can't seem to select multiple images to move into a folder in order to clean up my image library and organize it. Instead, I have to move each individual image into the folder and sometimes it takes MULTIPLE tries to get it to go in there. Am I missing
                                                                                                            • Error 550 5.4.1

                                                                                                              I’ve tried sending an email to someone but keep receiving this back. Any help would be greatly appreciated 
                                                                                                            • Automatic Matching from Bank Statements / Feeds

                                                                                                              Is it possible to have transactions from a feed or bank statement automatically match when certain criteria are met? My use case, which is pretty broadly applicable, is e-commerce transactions for merchant services accounts (clearing accounts). In these
                                                                                                            • Has Anyone successfully integrated Zoho and Sage Intact?

                                                                                                              Hey all, We’re evaluating Zoho One + Sage Intacct and I’m trying to connect with anyone who has actually implemented the two together.Specifically, I’d love to know: -- Which functions you kept in Zoho vs. Intacct (e.g., Product Catalog, AR/AP, invoicing,
                                                                                                            • Store "Sign in with Google/Microsoft/GitHub etc." details

                                                                                                              Quite often now, users are using a sign-in provider like Google or Microsoft to sign into various apps and services. It would be great if Vault could remember which providers you use for each website and sign you in with that provider instead of a username
                                                                                                            • Placing a condition before converting the LEAD

                                                                                                              Hi,  I need some assistance with Lead conversion. I need to place certain conditions before allowing the user to convert the lead.  For example: up until the certain status's doesn't equal "green" don't allow to convert lead.  I tried creating this using
                                                                                                            • 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
                                                                                                            • How can I filter a field integration?

                                                                                                              Hi,  I have a field integration from CRM "Products" in a form, and I have three product Categories in CRM. I only need to see Products of a category. Thanks for you answers.
                                                                                                            • Adding image in HTML report page

                                                                                                              Hi, I want to know two things: 1. Can anyone advise how to add an image in HTML report. The tagged used is <img> but what path do I mention for the image to be added in the HTML report. 2. Also, I want to know if I am creating an application for the market
                                                                                                            • How to change view of HTML report based on device but always print in A4

                                                                                                              Hello everyone, I am aware that HTML report view can be configured to adjust according to the screen size like Laptop, Tablet and mobile using media queries. But my concern is no matter on which device the reports is opened when printed should always
                                                                                                            • Age Calculation

                                                                                                              I've attempted to calculate the age of someone based on their birthday input by using the formula field. It works but I don't want all those decimals on there. I then tried to use "set variable" after birthday input but I get a field type mismatch, long vs. floating. Any ideas would be wonderful.
                                                                                                            • Search on Custom Field

                                                                                                              We're working on an integration with the Zoho FSM API and are trying to retrieve companies based on a custom field we added to the Companies module. However, we can't find a way to filter or query records using custom fields through the API. We have a
                                                                                                            • in zoho creator Sales Returns form has sub form Line Items return quantity when i upate the or enter any values in the sub form that want to reflect in the Sales Order form item deail sub form field Q

                                                                                                              in zoho creator Sales Returns form has sub form Line Items return quantity when i upate the or enter any values in the sub form that want to reflect in the Sales Order form item deail sub form field Quantity Returned\ pls check the recording fetch_salesorder
                                                                                                            • Sendmail function / custom action?

                                                                                                              I've setup a function hoping to email various business departments the details of a record once all work in that record is complete so gone about setting up a custom action in such way that each record line on the report has a button to click. Question is how do I actually include data from that record in the email that is sent when the button is clicked? I had thought that since this were being sent per record the email would include the data which had been entered
                                                                                                            • API to post drafts for social media

                                                                                                              I we want to post draft posts to our zoho social account and then approve and schedule them within Zoho social. is this possible with for example: https://apis.zoho.com/social/v2/post TIA Jon
                                                                                                            • Integración Books para cumplir la ley Crea y Crece y Ley Antifraude (VeriFactu)

                                                                                                              Hola: En principio, en julio de 2025, entra en vigor la ley Crea y Crece y Ley Antifraude (VeriFactu). ¿Sabéis si Zoho va a cumplir con la ley para cumplir con la facturación electrónica conectada a Hacienda? Gracias
                                                                                                            • Canvas View in Zoho Recruit

                                                                                                              Is it possible or would it be possible to have the new 'Canvas View' in Zoho Recruit?
                                                                                                            • What impactful sales coaching techniques have you used to boost your team's performance?

                                                                                                              I'm curious about the real-world impact of sales coaching on team performance. What specific techniques or strategies have you found most effective in driving consistent improvement and growth in your sales team? Any success stories or lessons learned
                                                                                                            • Adding Taxes to paid consultations in Zoho Bookings

                                                                                                              I created a 'paid' consultation under Zoho Booking and integrated it with payment gateways for online/instant payment before a booking is done. How can I add 'taxes' to the price of consultation? I can add taxes to other Zoho apps (liks Books, Checkout,
                                                                                                            • Next Page