I need autoupdate when event is saved it should autofetch in Activity log(Issue) childtable

Hi Community,
i had renamed Issue doctype to “Service Request”.
in issue doctype
childtable
Activity Log (Table)as custom_activity_log ,option as Event Activity Log
1.Event (link) as event
2.Date (datetime) as date
3.Remarks (texteditor) as remarks
4.Status (select) as status , options as Open,Completed,Closed

Event Doctype:
1.Starts on (datetime) as starts_on
2.Description (texteditor) as description
3.Status (select) as status , options as Open,Completed,Closed

what i need is in issue doctype in connection when select event and enter data that should fetch in activity log table
1.Event should fetch from Event id
2.remarks should fetch from description
3.date is fetch from starts on
4.status should fetch from status


frappe.ui.form.on('Issue', {
    event: function(frm) {
        // Trigger when the event is selected in the Issue doctype
        if (frm.doc.event) {
            // Fetch the selected Event details
            frappe.call({
                method: 'frappe.client.get',
                args: {
                    doctype: 'Event',
                    name: frm.doc.event  // Fetching the selected event by its name (ID)
                },
                callback: function(r) {
                    if (r.message) {
                        let event = r.message;

                        // Check if the event already exists in the custom_activity_log table
                        let existing_row = frm.doc.custom_activity_log.find(row => row.event === event.name);
                        
                        if (!existing_row) {
                            // Add a new row to the custom_activity_log child table
                            let row = frm.add_child('custom_activity_log');

                            // Populate fields in the custom_activity_log with Event data
                            row.event = event.name;  // Event ID (Link field to Event)
                            row.date = event.starts_on;  // Date (Datetime field from Starts On)
                            row.remarks = event.description;  // Remarks (Text editor field from Description)
                            row.status = event.status;  // Status (Select field from Event status)

                            // Refresh the child table to reflect the new entry
                            frm.refresh_field('custom_activity_log');
                        } else {
                            frappe.msgprint(__('This event is already added to the activity log.'));
                        }
                    }
                }
            });
        }
    }
});

above code i tried it is not working can u give me a solution for this
Thanks in Advance

Reference: Fetch Child table form one doctype to other doctype - #6 by NCP

i need from one doctype to another doctype childatble events doctype to Activity log{custom_activity_log} childtable in Issue doctype renamed as Service request now
Thanks in Advance

Concept and script look like same but you have to add the right logic according to the scenario.

when event is created from Service Request(Issue) following fields in Event Starts on ---- > Date in Service Request (issue doctype) (Activity log childtable), id in event ---- > Event in Service Request (issue doctype) (Activity log childtable),Description in Event ---- > Remarks in Service Request (issue doctype) (Activity log childtable), Status in Event ---- > Status in Service Request (issue doctype) (Activity log childtable)
Thanks in Advance

frappe.ui.form.on('Issue', {
    event: function(frm) {
        // Trigger when the event is selected in the Service Request doctype (renamed from Issue)
        if (frm.doc.event) {
            // Fetch the selected Event details
            frappe.call({
                method: 'frappe.client.get',
                args: {
                    doctype: 'Event',
                    name: frm.doc.event // Fetching the selected event by its name (ID)
                },
                callback: function(r) {
                    if (r.message) {
                        let event = r.message;

                        // Check if the event already exists in the custom_activity_log child table
                        let existing_row = frm.doc.custom_activity_log.find(row => row.event === event.name);
                        
                        if (!existing_row) {
                            // Add a new row to the custom_activity_log child table
                            let row = frm.add_child('custom_activity_log');

                            // Populate fields in the custom_activity_log with Event data
                            row.event = event.name;         // Event ID (Link field to Event)
                            row.date = event.starts_on;     // Date (Datetime field from Starts On)
                            row.remarks = event.description; // Remarks (Text editor field from Description)
                            row.status = event.status;      // Status (Select field from Event status)

                            // Refresh the child table to reflect the new entry
                            frm.refresh_field('custom_activity_log');
                        } else {
                            frappe.msgprint(__('This event is already added to the activity log.'));
                        }
                    }
                }
            });
        }
    },

    create_event: function(frm) {
        // Creating a new Event based on Service Request data (renamed from Issue)
        frappe.call({
            method: 'frappe.client.insert',
            args: {
                doc: {
                    doctype: 'Event',
                    subject: frm.doc.subject || 'New Event',  // Set subject for Event
                    starts_on: frm.doc.date || frappe.datetime.now_datetime(),  // Fetching Date from Service Request doctype
                    description: frm.doc.remarks || '',  // Fetching Remarks from Service Request doctype
                    status: frm.doc.status || 'Open'  // Fetching Status from Service Request doctype
                }
            },
            callback: function(r) {
                if (r.message) {
                    frappe.msgprint(__('Event created successfully with ID: ') + r.message.name);

                    // Set the Event ID in the Service Request and trigger the event fetch
                    frm.set_value('event', r.message.name);
                    frm.trigger('event');  // Trigger the event function to add it to the activity log
                }
            }
        });
    }
});

i need small changes for solution
Thanks in Advance