Welcome to Portal

?Unknown\pull-down

Welcome to Zoho Cares

Bienvenido a Soporte de Zoho

Search our knowledge base, ask the community or submit a request.

Hi.  I'm brand new to functions but I'm trying to create a script to convert a date field in Meetings to a written format.  For example, instead of 02/05/2025 8:00AM, I'd like to convert it to Wednesday, February 5, 8:00 AM.  My Date field is the API Name Start_DateTime, and the custom field I created is Meeting_Date_Written

Thank you so much for any help you can give me!

1 user has this question.
10 Replies
Reply

Hello Ric,

Welcome to Zoho Community. Thank you for adding your first post here in the community!

Can you help us with your use case in detail so we can check the possibilities from our end and help with the code here.

Looking forward to hearing from you.

Thank you Sunderjan.  Below is the script that I created in deluge.  It still seems to not be working:

void automation.JW_Date_To_Written(String id,Date Start_DateTime)
{
// Debug: Log the incoming parameters
info "Record ID: " + id;
info "Start DateTime: " + Start_DateTime;
// 1. Retrieve the meeting's start date/time from the parameter
a = Start_DateTime;
// 2. Format the date/time into a human-readable string.
//    This will output something like "February 06 2025, 08:00:00 AM".
b = a.toString("MMMM dd yyyy, HH:mm:ss a");
info "Formatted Date: " + b;
// 3. Create a map to convert a numeric day-of-week into a day name.
mp = Map();
mp.put(1,"Sunday");
mp.put(2,"Monday");
mp.put(3,"Tuesday");
mp.put(4,"Wednesday");
mp.put(5,"Thursday");
mp.put(6,"Friday");
mp.put(7,"Saturday");
// 4. Get the day of the week as a number (1-7) from the date.
c = getDayOfWeek(a);
d = mp.get(c);
info "Day of Week: " + d;
// 5. Concatenate the day name and the formatted date string.
e = d + ", " + b;
info "Final String: " + e;
// 6. Update the record's custom field "Meeting_Date_Written" with the final string.
recordMap = Map();
recordMap.put("Meeting_Date_Written",e);
updateResponse = zoho.crm.updateRecord("Events",id,recordMap);
info "Update Response: " + updateResponse;
}

Hi
 

Create a Workflow Rule triggered on the Edit/Create of Meetings records



Add an Instant Action to call a Function:



Configure and Write your own function:



Within the code editor, set up meetingRecordId as an argument to be dynamically passed into the function:



Include the following code within the body of the function (between the curly braces if using the new editor):

  1. meetingRecord = zoho.crm.getRecordById("Events", meetingRecordId);
  2. if(meetingRecord != null){
  3. meetingStartDateTimeISO = meetingRecord.get("Start_DateTime");
  4. if(meetingStartDateTimeISO != null){
  5. meetingStartDateTimeWritten = meetingStartDateTimeISO.replaceAll("T", " ").toDateTime().toString("EEEE, MMMM d, hh:mm a");
  6. updatedMeetingRecord = zoho.crm.updateRecord("Events", meetingRecordId, {"Meeting_Date_Written": meetingStartDateTimeWritten});
  7. }
  8. }

Save the function and the Workflow Rule.

===================
Powered by Haiku
===================

I also added these arguments:

id  Meetings-Meeting Date Written

Start_DateTime Meetings - From



 Thank you!

 thank you for pitching in.
 can you confirm if you were able to resolve the above?

Looking forward to hearing from you!

I wasn't... unfortunately.  I'm not getting an error, but the field isn't populating either.  

Hello Ric,

Give us a while, will check and get back to you on this with an update at the earliest.

Stay tuned!

You appear to have ignored the code I provided.

If you revisit that, you should be able to figure out the issues.

Hello Ric,

I would suggest you can try the below code and share the complete response screenshot. Please make sure the API name of the Meeting_Date_Written is correct.

// Debug: Log the incoming parameters
info "Record ID: " + id;
info "Start DateTime: " + Start_DateTime;
// 1. Retrieve the meeting's start date/time from the parameter
a = Start_DateTime;
// 2. Format the date/time into a human-readable string.
//    This will output something like "February 06 2025, 08:00:00 AM".
b = a.toString("MMMM dd yyyy, HH:mm:ss a");
info "Formatted Date: " + b;
// 3. Create a map to convert a numeric day-of-week into a day name.
mp = Map();
mp.put(1,"Sunday");
mp.put(2,"Monday");
mp.put(3,"Tuesday");
mp.put(4,"Wednesday");
mp.put(5,"Thursday");
mp.put(6,"Friday");
mp.put(7,"Saturday");
info mp;
// 4. Get the day of the week as a number (1-7) from the date.
c = getDayOfWeek(a);
d = mp.get(c);
info "Day of Week: " + d;
// 5. Concatenate the day name and the formatted date string.
e = d + ", " + b;
info "Final String: " + e;
// 6. Update the record's custom field "Meeting_Date_Written" with the final string.
recordMap = Map();
recordMap.put("Meeting_Date_Written",e);
info recordMap;
updateResponse = zoho.crm.updateRecord("Events",id,recordMap);
info "Update Response: " + updateResponse;

Looking forward to hearing from you!


Reply to Ric E DurdahlA
/* */
  • 12
  • Insert
  • Plain text
Add Comment
(Up to 20 MB )