Auto Run Custom Script Button in Internal

@rmehta @umair

I have created a button say ‘Start’ in a Custom DocType, now what this button does is when I click on Start it picks some leads meeting few conditions and assign those leads to some user meeting user condition. Till here all is good and working fine.

Currently, I have to run/click on that button manually every time I have to perform this action. Is there any way to repeat/auto trigger that button after every 5/10 minutes?

If NOT what could be a possible feature of the same and what will be the cost of Sponsoring?

Hi

try to use # Scheduled Tasks

To add a new task handler, go to hooks.py and add a new handler. Default handlers are all, daily, weekly, monthly, cron. The all handler is called every 4 minutes by default.

    # Scheduled Tasks
	# ---------------

	scheduler_events = {
		"daily": [
			"library_management.tasks.daily"
		],
		"cron": {
			"0/10 * * * *": [
				"library_management.task.run_every_ten_mins"
			],
			"15 18 * * *": [
				"library_management.task.every_day_at_18_15"
			]

I want handler to call a button which is part of CustomDoc and function for that button is written in Custom Script from front end.
Can I call/run that button every 5/10 minutes automatically function for which is written in custom script.

Hi

Example you want to run btn_1 auto run every 5 mins. You can add btn_auto to control: Start and Stop it,

var d = new Date();
cur_frm.cscript['btn_1'] = function() {
	console.log(d.getMinutes());
}

var btn_1_status = null;

cur_frm.cscript['btn_auto'] = function() {
	if(!btn_1_status){ //Start
		btn_1_status = setInterval(cur_frm.cscript['btn_1'], 1000*5*60);
	}else{ //Stop
		clearInterval(btn_1_status);
		btn_1_status = null;
	}
}

Will this continue to run (Auto Button = btn_auto) even after I have closed the page or I am on another page or I am even not logged automatically like Cron through Front End.

Will this continue to run (Auto Button = btn_auto) even after I have closed the page or I am on another page or I am even not logged automatically like Cron through Front End.

I think you must use hooks.py (in your app), can not use Custom script do it.