Filter Link in Web Form

Hello,

I know this has been asked before, but I am having a hard time filtering Projects in Web Form.

I have a Form so that Employees can send the hours they have been working on Tasks of Projects.

I have added the field Project, linked to Project in the proper Doctype, and I want that an eployee can only browse the Projects that are open, to reduce wasted time and higher mistake probability.

I have managed to filter the projects with an auxiliar Project field and a lot of code, but it has to be an easier way.

Thanks and kind regards,

Alb

You can do this by adding a small code in your Web Form’s JavaScript file, as shown below.

frappe.ready(function () {
	frappe.call({
		method: "frappe.client.get_list",
		args: {
			doctype: "Project",
			filters: { "status": "Open" },
			fields: ["name"]
		},
		callback: function (r) {
			let project_names = r.message.map(d => d.name);
			frappe.web_form.fields_dict.project.set_data(project_names);
		}
	});

});
1 Like

Many many thanks @Hemil_Sangani !!!

I knew it could be done more simple I was doing.

Thanks and kind regards from Spain,

Alb