I’m looking to create a banner that will appear across all doctypes in my Frappe/ERPNext instance. The goal is that whenever a user opens any form like Sales Order, Purchase Invoice, or Payment Entry they will see this banner at the top of the page.
DocType is a mandatory field in Client Script, so you can’t apply it globally from the UI.
The solution is using app_include_js in your custom app:
Step 1 hooks.py:
app_include_js = [“assets/your_app/js/global_banner.js”]
Step 2 global_banner.js:
$(document).on(‘form-refresh’, function() {
$(‘.global-system-banner’).remove();
$(‘.layout-main-section’).prepend(
<div class="global-system-banner" style="background:#fff3cd; border-left:4px solid #ffc107;color:#856404; padding:10px 16px; margin-bottom:10px;border-radius:4px; font-size:13px;">
<strong>Notice:</strong>Your message here.</div>
);
});
Step 3:
bench build --app your_app
This will show the banner on every doctype without needing to specify one.