Skip to content Skip to footer

Form script for opening the page after the scheduled time.

Description: This will open the form after the scheduled time. We can add scheduling in the form to define time and if the user tries to open this before time, it will show the alert.

function on_load(ws){
	var Scheduled_copy_Date = val(ws,'Work_Reschedule_On');
	var date = new Date();
	//tobe_set_date = date.getFullYear() + '-' + JSON.stringify(date.getMonth() + 1) + '-' + date.getDate();
	datestring = new Date(date.getFullYear(),date.getMonth(),date.getDate(),date.getHours(),date.getMinutes(),date.getSeconds(),0)
	//ws.setWidgetValue('s_Date_Time_2',tobe_set_date);sc
	var reggie = /(\d{4})-(\d{2})-(\d{2}) (\d{2})\:(\d{2})\:(\d{2})/;
	if(Scheduled_copy_Date && Scheduled_copy_Date != '')
	{ 
		var dateArray = reggie.exec(Scheduled_copy_Date);

		scheduled_date = new Date(Date.UTC(dateArray[1],dateArray[2]-1,dateArray[3],dateArray[4],dateArray[5],dateArray[6],0))
	}
	else
	{ 
		scheduled_date = datestring;
	}
	if(scheduled_date.getTime() > datestring.getTime()){
	var month = String(dateArray[2])
		if(month.length == 1){
		month = '0'+month
		}

		var json_value = JSON.stringify({'t':'Scheduled later','m':'This task is scheduled on : '+String(month + '-' + dateArray[3] + '-' + dateArray[1] + ' ' + ' ' + scheduled_date.getHours() + ':' + scheduled_date.getMinutes())})
		ws.closeForm(json_value);
	}
}

Was This Article Helpful?

0
0 Comments

There are no comments yet

Leave a comment

Your email address will not be published. Required fields are marked *

Close Bitnami banner
Bitnami