Auto Populate Date

Can anyone help me. In Item Price module there is a “Valid from” Field and i want the other field “Valid up to” to auto populate a date 6 months from the date in “Valid From” .

frappe.ui.form.on(‘Item Price’, {

  refresh: function(frm) {
     frm.fields_dict['valid_form'].df.onchange = function() {
        // Get the value of the source date field
        var sourceDate = frm.doc.valid_form;
        if (sourceDate) {
            // Calculate the date with a 6-month difference
            var sixMonthsLater = frappe.datetime.add_months(sourceDate, 6);
            // Set the target date field with the calculated date
            frm.set_value('valid_upto', sixMonthsLater);


Hi @xchicox,

It’s simple script for that.

Please apply the client script.

frappe.ui.form.on('Item Price', {
    valid_from: function(frm) {
        frm.set_value('valid_upto', frappe.datetime.add_months(frm.doc.valid_from, 6));

Then reload and check it.

Thank You!

is there a way that it will update automatically instead of updating the"valid from" before the “valid up to” to populate


refresh: function(frm) {

// OR

onload: function(frm) {

Thank you so so much it worked