I am currently trying to create a workflow as follows: When a record is created in one module (Volunteer Events), it takes what is in the "Areas Requested" multi-select field and sends an email to each match on a "Areas of Interest" multi-select field in another module (Volunteers). For example, when an event is created with the Areas Requested being Data;Art;Cooking, it sends an email out to volunteers in the Volunteers module who have Areas of Interest containing Data, Art, or Cooking (checking one by one respectively). Here is my code.
// Fetch the event details from the new Volunteer Event record
contactMap = zoho.crm.getRecordById("Volunteer_Events",areasRequested);
eventName = contactMap.get("Name");
eventBlurb = contactMap.get("Event_Blurb");
eventAreas = contactMap.get("Areas_Requested");
// Initialize a list to store volunteer email addresses
volunteerEmails = list();
// Loop through each area of interest to find matching volunteers
for each area in eventAreas
{
// Search for volunteers with matching tags
volunteers = zoho.crm.searchRecords("Volunteers","(Tags:equals:" + area + ")");
for each volunteer in volunteers
{
// Add volunteer email to the list (avoid duplicates if necessary)
email = volunteer.get("Email");
if(email != null && !volunteerEmails.contains(email))
{
volunteerEmails.add(email);
}
}
}
// Create the email content
emailSubject = "Upcoming Volunteer Event";
emailBody = "Hello,\n\nWe are excited to announce an upcoming volunteer event:\n\n" + "Event Name: " + eventName + "\n" + "Description: " + eventBlurb + "\n\n" + "Best regards";
// Send email to each volunteer
for each email in volunteerEmails
{
sendmail
[
from :zoho.adminuserid
to :email
subject :emailSubject
message :emailBody
]
}
So the code works and everything saves, meaning there is no error when trying to save the function itself.. However, when I try to test it by adding a record on Volunteer Events, it gives me the following error: Data type of the argument of the function '756' did not match the required data type of '[BIGINT]'at lineNumber 4.