Hi
Help is required in the client script for Serial no. doc type
use case:
I have a field Extended warranty expiry date which will get updated as per the Extended warranty period selected (suppose 6 or 12 months)
The following is the client script used
frappe.ui.form.on('Serial No', {
refresh(frm) {
function compute(doc, cdt, cdn){
{ if(doc.extended_warranty_period == "6")//it's check if the fields contains a value
doc.extended_warranty_expiry_date = frappe.datetime.add_months(doc.warranty_expiry_date, 6);
if(doc.extended_warranty_period === "")//it's check if the fields contains a value
doc.extended_warranty_expiry_date = "";
if(doc.extended_warranty_period == "12")//it's check if the fields contains a value
doc.extended_warranty_expiry_date = frappe.datetime.add_months(doc.warranty_expiry_date, 12);
//if(x != "0")//it's check if the fields contains a value
//doc.extended_warranty_status = "Covered";
var x = frappe.datetime.get_day_diff(doc.extended_warranty_expiry_date, frappe.datetime.nowdate());
if (x > 0)
doc.extended_warranty_status = "Live";
if (x < 0)
doc.extended_warranty_status = "Expired";
if (doc.extended_warranty_period === "")
doc.extended_warranty_status = "Not Covered";
}
}
cur_frm.cscript.custom_extended_warranty_period = compute;
// your code here // your code here
}
})
But this works good when i open the document and update the “extended warranty period” field It automatically updates the extended warranty expiry date.
But when i try to update using the list view > action > edit> field update
it is not working.
I do this because i wanted to update 100 records in one time.
Kindly help on this