Lock form after 09:00

Forums Classic DFFS Lock form after 09:00

Viewing 9 reply threads
  • Author
    Posts
    • #28442
      Steve
      Participant

      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

    • #28444
      Alexander Bautz
      Keymaster

      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

    • #28449
      Steve
      Participant

      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

    • #28453
      Alexander Bautz
      Keymaster

      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

      • #28455
        Steve
        Participant

        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

    • #28457
      Alexander Bautz
      Keymaster

      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

    • #28459
      Steve
      Participant

      Sorry, the output does not show anything. I should have added the attachment.

    • #28462
      Alexander Bautz
      Keymaster

      Which version of DFFS are you running?

      Alexander

    • #28468
      Alexander Bautz
      Keymaster

      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

    • #28470
      Steve
      Participant

      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.

    • #28795
      Steve
      Participant

      Thank you Alex again, we’ve updated DFFS version to the latest. DateObject has started to work.
      Steo

Viewing 9 reply threads
  • You must be logged in to reply to this topic.