I am trying to implement a "Create Note" button in the Leads module with the following functionality:
1. When the button is clicked, a form should pop up with fields to add notes.
2. After filling out the form and clicking Send, the note should be added to the lead record.
I created a custom button and a custom function to add notes. However, I faced input text limitations in the Deluge script.
To address this, I created a client script to display a popup form.
When I click the button, the popup form is not appearing. Instead, notes are being created directly without showing any form.
Can anyone guide me on how to fix this issue or suggest an alternative approach to achieve the desired functionality?
Custom Function:
string button.Create_note_function(String leadId, String noteId, String noteTitle,String noteContent)
{
// Validate the Lead record
lead = zoho.crm.getRecordById("Leads",leadId);
if(lead == null)
{
return "Invalid Lead ID: " + leadId;
}
// Create note details
noteDetails = Map();
noteDetails.put("Note_Title",noteTitle);
noteDetails.put("Note_Content",noteContent);
noteDetails.put("$se_module","Leads");
noteDetails.put("Parent_Id",leadId);
// Save the note
response = zoho.crm.createRecord("Notes",noteDetails);
// Check if the note was successfully added
if(response.get("id") != null)
{
return "Note successfully added for Lead ID: " + leadId;
}
else
{
return "Error adding note: " + response.get("message");
}
}
Client Script:ZOHO.CRM.UI.Popup.create({
title: "Add Note",
template: "function",
data: {
fields: [
{ name: "noteTitle", label: "Note Title", type: "text", required: true },
{ name: "noteContent", label: "Note Content", type: "textarea", required: true }
],
save: function (data) {
ZOHO.CRM.API.executeFunction("Create_note_function", {
arguments: {
leadId: ZOHO.CRM.page.getCurrentEntityId(),
noteTitle: data.noteTitle,
noteContent: data.noteContent
}
}).then(function (response) {
if (response.code === "success") {
ZOHO.CRM.UI.Popup.alert("Note successfully added!");
} else {
ZOHO.CRM.UI.Popup.alert("Error adding note: " + response.message);
}
});
}
}
});