Bulk action doesn't trigger custom scripts

Hi ,

I have a custom script that’s triggered before Submit of a custom doctype and it works fine when the docs are submitted individually. It however appears that Submitting multiple docs via bulk action in list view doesn’t trigger the custom script! Is this a bug?

Any ideas pls?

Kind regards,

Still hoping for some assistance / suggestions here please

Thanks plenty

Submitted a Github issue:

https://github.com/frappe/erpnext/issues/21931

In the meantime, would appreciate any suggestions as to how this can be achieved even if programmatically

Thanks

I found out that bulk submit actually execute the validate trigger, so for your custom code to work on bulk submit, you need to put your code in the validate trigger. Find or create a condition if self._action == 'submit' in validate trigger

2 Likes

You may try server side scripts or you may try hooks. Custom scripts are client side and they are loaded when form is refreshed/loaded/rendered etc. So, most probably your script isn’t loaded thus isn’t executed. I don’t think Frappe will ever let you execute your custom scripts when doing bulk actions.

3 Likes

Hi @iqbalfeb

Thanks a lot for your response. Could you pls explain this a bit more? The condition you suggested seems to be server side. How is this included in the custom script? Pls give a simple example if possible

Thanks

Yes, this solution works for server side. I haven’t tried with custom script in the client side. Maybe you can be more specific with your code (or put a bit of that custom script here) so maybe we can propose a solution

Hi @iqbalfeb

Please see code snippet below:

frappe.ui.form.on('Appraisal', {
	before_submit: function(frm) {
		var d = (frm.doc.total_score / 5) * 100;
	    cur_frm.set_value("percentage_score", d);
	}
}) 

Any suggestions pls ?

So you want to calculate a score when submitting the document. I would try it with Server Side Script.

any update about this

Server Script still viable solution.