In the Web form’s List view I want to add a filter to the project field .How can i gain access to this Web Form’s list page ? I can access the Doctype’s List view with this code .
frappe.listview_settings["Doctype'] = {
}
But how can I gain access to web form’s Listview .
This code of @rik_sanchez is designed to add a custom project filter to a web form list in Frappe.
Ideally, you have to be a 50% techie to get this sorted. Will explain.
The code runs when the Frappe framework is ready (frappe.ready )
It sets up a MutationObserver to watch for changes in the DOM, specifically looking for changes in the child elements or attributes of the target node (.web-list-table ).
When a mutation is detected, it checks if frappe.web_form_list exists and has elements.
If the condition is met, it makes an API call to a specified method (path ) with the current user as an argument.
Upon receiving a response, it processes the data to create a list of project options.
It creates a Select control with the project options and adds it to the web form list filters.
It applies custom styles, tooltips, and placeholders to the select control.
When a project is selected, it updates the filters in frappe.web_form_list and refreshes the list.
Finally, it disconnects the observer to stop watching for further mutations.
This code should be a Client Script because it interacts with the DOM and performs actions based on user interactions and changes in the web form list. Client scripts are designed to run in the browser and handle such tasks.
Client scripts are easier to manage by the end user.