here is the code which takes params from url and sets the fields of web form
but i am getting error with frm.set_value()
so how can i set field values of a web form with form script?
frappe.web_form.validate = (frm)=>{
console.log('in validate')
// Get the parameters from the URL
let url = window.location.href;
let urlParams = getUrlParams(url);
//var urlParams = frappe.utils.get_url_params();
console.log('urlParams:',urlParams);
// Set field values based on URL parameters
if (urlParams.asset_id) {
console.log('asset_id:',urlParams.asset_id);
frm.set_value('asset_name', urlParams.asset_id);
}
if (urlParams.id) {
frm.set_value('asset_id', urlParams.id);
}
if (urlParams.branch) {
frm.set_value('branch', urlParams.branch);
}
if (urlParams.floor) {
frm.set_value('floor', urlParams.floor);
}
if (urlParams.department) {
frm.set_value('department', urlParams.department);
}
console.log('after if st:');
// Refresh the form to reflect the changes
frm.refresh();
}