First Created Time Date

First Created Time Date

Hi, Wonder if anyone can help... so we have enquiries coming into a custom module and sometimes customers have submitted more than one, I would like to ensure that if a new field within the contacts module "First Enquiry date" is empty that it populates this with the first created time out of all enquries made, e.g X made an enquiry 22/11/2023 but has previously made 5 others with the first record being created 20/04/2023 (I would like this date adding as the first enquiry date in the contact.

Here is the code below, but it doesnt seem to be playing ball?

gcus = zoho.crm.getRecordById("Enquiry_Detail",eid);
//info gcus;
gcid = gcus.getJson("Contact_ID").getJson("id");
info gcid;
gc = zoho.crm.getRecordById("Contacts",gcid);
//info gc;
gd = gc.getJson("First_Enquiry_Date");
if(gd == null)
{
grel = zoho.crm.getRelatedRecords("Enquiry Detail","Contacts",gcid);
// info grel;
for each  ele in grel
{
gcrt = ele.getJson("Created_Time");
// info gcrt;
}
info gcrt;
// nd = gcrt.getPrefix("T").toString();
// mp = map();
// mp.put("First_Enquiry_Date", nd);
// info mp;
// up = zoho.crm.updateRecord("Contacts", gcid, mp);
// info up;
}

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns 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