Hi,
my client wants, read only option for some fields in child table after particular time.
I have one doctype called “Daily Sales Activity”, there one child table “Activity Table” & field name is “activity”. In that child table, i have 3 fields activity_type(select), decription(data) & status(select).
Scenario: They fill the details on activity_type, description & status row in morning 9am to after noon 2pm. Now, they want after 3pm, the fields activity_type, description are not editable only status field should be allow to edit.( I mean already filled rows).
So, for this scenario, i have created one client script but its not working. I attaced that code below.
frappe.ui.form.on('Daily Sales Activity', {
onload: function(frm) {
frm.fields_dict['activity_table'].grid.on('row_added', function() {
const now = new Date();
const hours = now.getHours();
// Disable fields if it's after 3 PM
if (hours >= 15) { // 3 PM
frm.set_df_property('activity_type', 'read_only', 1);
frm.set_df_property('description', 'read_only', 1);
}
});
},
refresh: function(frm) {
const now = new Date();
const hours = now.getHours();
// Disable fields if it's after 3 PM
if (hours >= 15) { // 3 PM
frm.set_df_property('activity_table', 'read_only', 1);
}
}
});