prevent users from adding items during a specific time


Badge +9

Is there a way, with a workflow, to prevent users from submitting items into a list after 3pm and have them submit items the next day at 7am? Is this possible to do?


11 replies

Userlevel 5
Badge +12

Hi Rency - I think you could pull this off several different ways depending on the reqs.  For example, if your workflow itself was responsible for creating the item, then you could check against the time and restrict as necessary.   This would only work if you had a workflow sitting between your input (form) and the target (list).   There are probably other methods that would involve coding against a List Event receiver and utilizing the SPItemEventReceiver.ItemAdding method but that would be custom code and not utilizing a workflow.   An alternative to both of these might be to allow them to add the item to the list via the form whenever, but put the item into a "waiting" state until 7am the next day when it is auto processed by the workflow.   Just some ideas off the top of my head, others may have more!

Userlevel 6
Badge +12

I was thinking along the lines that Mike M​ mentioned above; allow users to "submit" the item, but have the workflow check the current time and if it is after 3pm, change a status to "hold". You could then have a daily site workflow that would kickoff at 7am each morning and change all item's status that are "hold" to "submitted" and kick off any subsequent workflow. With this in mind, any items submitted between 7am and 3pm would come in as "submitted".

Alternatively, you could add a Pause Until action step in place of the status. This would cause the workflow to run overnight and is generally not recommended, but would not require you to develop and implement a daily site workflow.

Badge +9

Hi Jesse

Thank you for helping me....can you tell me what action to specifically use to check the if the current time is after 3pm? How do I specify 3pm ?

Userlevel 6
Badge +12

What I did was first use the Calculate Date action and checked "Use date when action is executed". Be sure that the "Include Time" is NOT CHECKED. I then added 15 to Hours (to get to 3pm) and stored the result in a variable:

175011_pastedImage_0.png

After that step, use the Set a Condition action to check if the Created field of the item is greater than the stored variable:

175012_pastedImage_1.png

At this point you have two directions; one that was submitted before 3pm and one that was submitted after 3pm. Simply add in your desired logic for each branch and you're good to go.

Heads up - you will need to account for if the item was created before 7am (based on your original post). If you are going down this road, perhaps looking at if the Created field is within a window like this:

175136_pastedImage_2.png

Your endOfDay would be the same as above (+15 hours) and the startOfDay would be similar, but +7 hours (for 7am). Then compare the Created to both:

175138_pastedImage_4.png

If the Created time stamp is greater than 3p OR less than 7a of the day that the WF is running, it is not "submitted" (or any other logic you want to build in!)

Hope this helps!

Userlevel 5
Badge +12

Hi Rency,

Use the {Common:CurrentTime} variable built into the designer under the common tag to get the current time to tell if its 3pm or not.  Note that this is "server" time and not necessarily the client's time for their timezone.  Jesse did a good job further expanding on my statement "An alternative to both of these might be to allow them to add the item to the list via the form whenever, but put the item into a "waiting" state until 7am the next day when it is auto processed by the workflow."    Basically you'll have a scheduled workflow that runs at 7am and picks up processing on items submitted after the 3pm mark of the prior day.

-Mike

Badge +9

Thank you so much Mike happy.png

Badge +9

Thank you Jesse...I am trying this out right now. happy.png

Badge +9

Hi Jesse

I tried the following however it is not putting items in Submitted status

175806_pastedImage_0.png

175807_pastedImage_1.png

175808_pastedImage_2.png

175809_pastedImage_3.png

The items should go down the Yes branch because I added items in before 10am this morning but it is going down the no branch.

I tried the following but it didn't work.

175810_pastedImage_4.png

Userlevel 6
Badge +12

My apologies. Use AND not OR for the Set a condition action and flip the less than/greater than:

175812_pastedImage_7.png

What you want to assess is whether or not the item was submitted within a window. So we should be look at it this way:

Created < endOfDay AND Created > startOfDay

This ensure that it was submitted after a time AND before a time.

I did a test run (to validate happy.png) and it goes through:

within window:

175813_pastedImage_12.png

before window:

175814_pastedImage_19.png

after window:

175815_pastedImage_20.png

When using OR if either of them resolve as true it would go through, and that is not what we want.

Let me know how it works out for you!

Badge +9

Works thank you!

Userlevel 6
Badge +12

Awesome! Glad to hear it!

Reply