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