Customizing Web Form

i am creating a web form called ticket which I duplicated from issue . This customer field automatically fetches the name of the user that is logged in after I hit the submit button .
I want to fetch the Service Level Agreement for that customer according to the Customer. By using frappe call i can fetch any service level agreement but i can’t get access according to the customer . Here i have hard coded to fetch a service Level Agreement .

.js

frappe.ready(function() {
			frappe.call({
				method:"fusion_support.fusion_support.web_form.tickets.tickets.value_fetch",
				callback:(data)=>{
					if(data.message){
						frappe.web_form.set_value("service_level_agreement",[data.message])
					}
				}
			})
});

.py



@frappe.whitelist(allow_guest=True)
def value_fetch():
    data = frappe.db.get_value("Service Level Agreement",filters={"entity":'Grant Plastics Ltd.'},fieldname=['name'])
    return data

If any one has experience on the .py file can you enlighten me on how I can achieve this ?

1 Like