How to Refresh the page and doctype once automatically

Hi all,
I have created the page by overwritting the css and when moving to any doctype it is not automatically refreshed and showing that doctype as expanded. when refresh the page comes to normal.

Even when moving from the page to doctype the changes done in the page are not automatically reflected to the doctype. When refresh it is done. How to do the auto refresh in the doctype.

from page, you can add button to refresh page or call function me.refresh() if refresh is function defined.

From DocType, in custom script you can write cur_frm.refresh(); to refresh page

Hi @kolate_sambhaji Thanks for your Reply,

When Moving from Page to Doctype or Doctype to Page, that time how to set autorefresh.

For Page to DocType,
You can write custom script, so every time page is refreshed before loading

frappe.ui.form.on("DocType", "onload", function(frm) {

Why would you want to do that. Seems like a not so good move.

I want to write custom script for the customer list .(For example: when user enters a new customer, then the customer list page doesn’t reload automatically)
please help for the refresh script

Thanks & Regards
Satish M

Hello Satish.

Here is something you can do… I just tested it and it works well.

frappe.ui.form.on("Customer", {
	onload: frm => {
		const { needs_to_reload } = localStorage;

		if (needs_to_reload && needs_to_reload == "true") {
			localStorage.setItem("needs_to_reload", "false");


window.onhashchange = () => {
	const condition = true; // conditions here

	if (condition) {
		localStorage.setItem("needs_to_reload", "true");

I used the localStorage object to flag the browser and track if the page needs to be reload based on the changes of the URL of your browser.

Hint: You can add it on your customer_list.js if you wish, however I would recommend to add a global JS file and then append that file via hooks to the whole app so that you have a broader scope.

1 Like