Client Script for Day of the Week on Child Table

Hi! Need help on client script for day of the week for a child table:

Doctype: Monthly Work Plan
Table field name: activities
Table Name: MWP Table

Within MWP Table:
field name is “date” and upon selection of date, day of the week should automatically populate in field name “day”

Help pls!

@mehmehly you need to the the day like it’s Monday or Tuesday ?

Yes. For example, if I select October 24, 2023 for field name “date” belonging to child table “MWP Table”, field name “day” belonging to child table “MWP Table” should return “Tuesday”. How do I code that in client script? @bahaou

@mehmehly Try this

frappe.ui.form.on("MWP Table", {
  date: function (frm, cdt, cdn) {
    var child_row = locals[cdt][cdn];
    if ( {
        var day_of_date = moment('dddd');
        frappe.model.set_value(child_row.doctype,, "day", day_of_date);

@mehmehly Is it worked for you ?

Worked perfectly! Thanks so much!

1 Like