I need to know in which .js file in which folder I have to place code to add a event to a custom button, which is not in one of any custom app, but in the Time Log App of ERPNext.
I have added the button already, but I can’t figure out where to place the JavaScript / jQuery Code properly to make it work.
Include it in that doc’s [docname].js file. You can use the same syntax of frappe.ui.form.on(“Doctype”, “your_button”, function(…){});
Include it in a custom script bound to that doctype. cur_frm.cscript.your_button = function(…
Include it in a custom app somewhere in appname/public/js/[your file here], with the same exact function you’d use above. Then, in that app’s hooks, in app_include_js, either hook it directly, or create a build.json in your public folder including that file. The js file will be included in the page head and the event will run. More detail on the build process here: Calendar view for sales opportunity? - #8 by ericmachine88
The third way is more setup but provides you much more flexibility - you don’t have to manage a bunch of custom scripts through the UI, you don’t have to edit a Frappe/ERPNext document and therefore avoid merge conflicts, and so on. It’s more setup up front but it’s what I use now for any js that executes on a standard doc.