Any Idea to run JS script on any/specific doctype?

Hi @PyJumper,

If you want to apply the logic for mutiple doctype then apply it in the utils.js in your custom app. then add it in the bundle js.

hooks.py

app_include_js = "your_custom_app.bundle.js"

your_custom_app.bundle.js

import "./utils";

/public/js/utils.js

$(document).on('app_ready', function() {
	$.each(["Opportunity", "Quotation", "Supplier Quotation", 
		"Sales Invoice", "Delivery Note",  "Sales Order",
		"Purchase Invoice", "Purchase Receipt", "Purchase Order"], function(i, doctype) {
			frappe.ui.form.on(doctype, {
				refresh: function(frm) {
					// add you logic
				}
			});
	});
});

Migrate the site, and build the app.

10 Likes