I am new to Frappe. I have a requirement for integrating Frappe into my website. The website is developed using some other technology and not using Frappe. In that website, I want to add a button/link that will execute a JavaScript to open a Frappe Form (for a specific DocType) by passing the necessary query filters.
Please let me know how to achieve this?
Create a custom doctype : My Script Runner
And add custom script:
frappe.ui.form.on("My Script Runner", {
refresh(frm) {
const url = window.location.href;
const index = url.indexOf("#");
const hash = url.substring(index + 1);
const params = hash.split("?").pop();
const urlSearchParams = new URLSearchParams(params);
if (
hash &&
params &&
urlSearchParams.get("customer") &&
urlSearchParams.get("fromDate") &&
urlSearchParams.get("toDate")
) {
frappe.set_route("query-report", "General Ledger", {
party_type: "Customer",
party: urlSearchParams.get("customer"),
from_date: urlSearchParams.get("fromDate"),
to_date: urlSearchParams.get("toDate"),
});
}
},
});
Now visit https://my.erpsite.com/desk#Form/My%20Script%20Runner?customer={customer_name}&fromDate=2020-10-01&toDate=2020-11-01
This will load GL Report. Change script as per need, use frappe router.
This will work on cloud in desk with hash routing. Upto v12.
rebrand-ui onwards change the routes accordingly.
1 Like
Thanks for a prompt response. I will try it out.