ERPNext Conference 2019* ERPNext.com Blog

Triggering function on load of doctype list view


#1

Hello World,

I’m trying to trigger a function on load of a doctype’s “list view”. I know about

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

but that will not run on a doctype’s “list view”. It will run on the New {DocType} view.

I also know about

onload: function(listview) {

}

but that will also not run on a doctype’s “list view”. It will run on load of a doctype and it will run the functions in the “listview”.

What is the trigger for this event?

Here is the ToDo doctype’s list view:


ERPNext integration with Signaturit
#2

Refer below link.


#4

Thanks @suyash for the reply.

That doesn’t solve my issue. This is just the same as I was talking about. It is “onload” of the “New {DocType}” view. It is adding new menu items to the list view page but it isn’t triggered when a user visits that page


#6

could be same error as:


#7

@JoEz

Thanks for the help.

What I have isn’t really an error, it may be a feature request or maybe the feature already exists, I’m not sure. I don’t think your link helps me though.

Thanks anyway


#8

Have you found a solution? ,
I also encountered a problem similar to yours


#9

For list view operations you might create a file like doctypename_list.js under the respective doctype folder.

After that you can write a onload function inside this list file.


#10

Ex.
12


#11

thank you for your answer ,

but that still isn’t a solution.

onload only occurs when you press the F5 or Refresh button.

but when you open via the Search function it won’t work anymore

let’s just say it happens only once. whereas I want to run the script when I open the list


#12

You can write a code on refresh function instead onload

Ex. refresh: function(frm){
}

it will works on Search function too


#13

I tried it, the function didn’t work

frappe.listview_settings['Payment Entry'] = {
  refresh:function(frm){
            console.log("Running Function this");
       }
 
}

#14

hey, remove ‘=’ from you code


#15

hey guys

Is there any trigger when i select purchase order list check box. you can see in image


#16

Facing Same issue…

In list view, refresh function not working