Home › Forums › Classic DFFS › Lock form after 09:00
Tagged: lock fields, Lock Form
- This topic has 11 replies, 2 voices, and was last updated 4 years, 9 months ago by Steve.
-
AuthorPosts
-
-
January 30, 2020 at 20:09 #28442
Hello guys,
is there any possibility the form to be locked at 09:00 every day? If it’s [today] date, lock the form at 09:00.
The next day’s items in the list can be editable until it’s the due date.
Example:
Order for 31st January 2020. I can edit it now, but I should not on 31st January at 09:00.
Thank you very much in advance.
Steo -
January 30, 2020 at 22:03 #28444
I don’t understand exactly what you mean. Do you want to lock ALL items in the list at 09:00, or only those that has a due date on that same day?
And if the item has a due date “today” – locking it at 09:00 should keep it locked permanently?
Alexander
-
January 31, 2020 at 06:54 #28449
I don’t understand exactly what you mean. Do you want to lock ALL items in the list at 09:00, or only those that have a due date on that same day?
Only those that have a due date on that same day.
And if the item has a due date “today” – locking it at 09:00 should keep it locked permanently?
Yes, keep it locked permanently after “today” – 09:00.
Steo
-
January 31, 2020 at 17:15 #28453
Put this in Custom JS in your EditForm:
var due = spjs.utility.getDateFieldAsDateObject("YOUR_DATE_FIELD_INTERNAL_NAME"); var todayAt0900 = new Date(); todayAt0900.setHours(9, 0, 0); if (due < todayAt0900) { jQuery("#part1").hide(); spjs.dffs.alert({ "title": "No access", "msg": "This item is locked because the due date has passed.", "ok": function () { location.href = location.href.split("EditForm.aspx").join("DispForm.aspx"); } }); }
Replace YOUR_DATE_FIELD_INTERNAL_NAME with your fields internal name.
Let me know how it works out.
Alexander
-
January 31, 2020 at 19:31 #28455
Thank you, Alex, so much.
It is not working:var due = spjs.utility.getDateFieldAsDateObject("objNaDate"); var todayAt0900 = new Date(); todayAt0900.setHours(9, 0, 0); if (due < todayAt0900) { jQuery("#part1").hide(); spjs.dffs.alert({ "title": "No access", "msg": "This item is locked because the due date has passed.", "ok": function () { location.href = location.href.split("EditForm.aspx").join("DispForm.aspx"); } }); }
Field Internal Name is OK. Developer console in Google Chrome does not show any errors.
Thank you.
Steo
-
-
January 31, 2020 at 19:59 #28457
Hard to tell without looking at it in your list, but you can start with using console.log to log due and todayAt0900 like this:
var due = spjs.utility.getDateFieldAsDateObject("objNaDate"); console.log(due); var todayAt0900 = new Date(); console.log(todayAt0900); todayAt0900.setHours(9, 0, 0); if (due < todayAt0900) { jQuery("#part1").hide(); spjs.dffs.alert({ "title": "No access", "msg": "This item is locked because the due date has passed.", "ok": function () { location.href = location.href.split("EditForm.aspx").join("DispForm.aspx"); } }); }
What do they output?
Alexander
-
January 31, 2020 at 20:17 #28459
Sorry, the output does not show anything. I should have added the attachment.
Attachments:
-
January 31, 2020 at 20:51 #28462
Which version of DFFS are you running?
Alexander
-
January 31, 2020 at 20:56 #28464
-
-
January 31, 2020 at 20:59 #28468
I’m not able to check the change log now, but it looks like you need to update to a later version for this to work.
Alexander
-
January 31, 2020 at 21:01 #28470
Ok, I hope it won’t be complicated and not delete all configuration.
I’ll let you know when I’m done.
It will probably take some time.
Thank you Alex,
Steo. -
February 22, 2020 at 10:41 #28795
Thank you Alex again, we’ve updated DFFS version to the latest. DateObject has started to work.
Steo
-
-
AuthorPosts
- You must be logged in to reply to this topic.