Update all the related records by custom function

Update all the related records by custom function

Hi, i have this following Function - 

// This custom function is triggered when the parent module record is edited

// Fetch the details from the edited record
ParentModuleName = "Courses"; // Replace with your actual Parent Module API name
RelatedListModuleName = "relatedlist"; // Replace with your actual Related List Module API name

ParentRecords = zoho.crm.getRecordById(ParentModuleName, CourseID.toLong());

FieldAValue = ifnull(ParentRecords.get("field1"), "");
FieldBValue = ifnull(ParentRecords.get("field"), "");

// Update the related list records with the values from Field A and Field B
RelatedListRecords = ParentRecords.get(RelatedListModuleName); // Assuming a related list field with the API name of Related List Module

for each RelatedListRecord in RelatedListRecords
{
    // Update Field A and Field B in each related list record
    RelatedListRecord.put("field1", FieldAValue);
    RelatedListRecord.put("field", FieldBValue);

    // Save the changes to the related list record
    zoho.crm.updateRecord(RelatedListModuleName, RelatedListRecord.get("id"), RelatedListRecord.toMap());
}

for now - this function update the latest related list Records
but i want him to update for me the all related list records that the parent module have

last assume there is 10 related list records
and i am edit the parent module field, so i want the all 10 related list records will be edited by the same info there is in the parent module

what should i change or add to the custom function

    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