Hi, could someone please cast their eye over this script to see what I’m doing wrong?
I have been through some other posts and have tried to copy journal_entry.js, but this script doesn’t appear to get run at all. I have tried restarting the dev server (bench start), clearing cache, refreshing my browser…
Background: Web Page Section
is a parent doctype with Table field items
that points to child doctype Web Page Section Item
, which has fields content_doctype
(Select) and content_document
(Dynamic Link pointing to content_doctype).
I’m trying to add a dynamic filter to the Dynamic Link. The script is in a file called web_page_section.js
in the directory with the same name along with the web_page_section.py
file that does get run.
frappe.ui.form.on("Web Page Section", {
onload: function(frm) {
var me = this;
me.frm.set_query("content_document", "items", function(doc, cdt, cdn) {
const item = locals[cdt][cdn];
console.log("This is the item name: " + item.name + cdt + cdn);
if (item.content_doctype==="Blog Post") {
return { filters: {'published': 1} };
} else if (item.content_doctype==="Item") {
return { filters: {'show_in_website': 1} };
} else {
return {};
}
});
}
});
(and before anyone points it out, I know the functionality is vaguely similar to frappe’s Web Page page builder)
TIA!