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