How can I fetch the day in the “From” date, and put it in the table if particulars is “Date” for the column “Sunday”? Can someone help me correct my script?
frappe.ui.form.on('Sales Expense Liquidation', {
refresh: function (frm) {
},
from: function (frm) {
var fromValue = frm.doc.from;
if (fromValue) {
var day = new Date(fromValue).getDate();
} else {
var day = null;
}
var childTable = frm.doc.header;
$.each(childTable, function (index, row) {
if (row.particulars === "Date") {
frappe.model.set_value(row.doctype, row.name, 'sunday', day);
}
});
frm.refresh_field('header');
}
});
New code. Tested and Working:
You will have to modify the name of your fields, etc.