I got a request for a solution to limit access to a form for 30 minutes while a report was being made to ensure no records was added or modified.
This example code must be added to the specific form – in the Custom JS section. Change the from, to and weekdays to match the time and weekdays you want to limit access.
function limitAccessToForm(arg) { var disableStart = new Date(); disableStart.setHours(arg.from.hour, arg.from.minute, 0); // hour, minute, second var disableEnd = new Date(); disableEnd.setHours(arg.to.hour, arg.to.minute, 0); // hour, minute, second var disableStartFriendly = disableStart.toLocaleString(); var disableEndFriendly = disableEnd.toLocaleString(); var now = new Date(); if (now > disableStart && now < disableEnd) { if (arg.weekdays.length > 0) { var pass = false; var today = now.getDay(); jQuery.each(arg.weekdays, function (i, day) { if (today === day) { pass = true; return false; } }); if (!pass) { // Not today return; } } jQuery("#part1").css("visibility", "hidden"); spjs.dffs.alert({ "title": "No access", "msg": "This form is disabled between " + disableStartFriendly + " and " + disableEndFriendly, "ok": function () { if(GetUrlKeyValue("IsDlg") === "1"){ window.frameElement.cancelPopUp(); }else{ window.history.back(); } } }); } } // If you like to limit it to specific weekdays add them to the array weekdays (sunday = 0 and saturday = 6) - leave the array empty if you want it on all weekdays limitAccessToForm({ "from": { "hour": 13, "minute": 0 }, "to": { "hour": 13, "minute": 30 }, "weekdays": [] });
Post any comments below, or in the forum.
Alexander