rencygonzalez
Novice

prevent users from adding items during a specific time

Jump to solution

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?

Tags (1)
0 Kudos
Reply
11 Replies
xMikeX
Scholar

Re: prevent users from adding items during a specific time

Jump to solution

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!

Reply
jesse_mchargue
Nintex Workflow Cloud Expert
Nintex Workflow Cloud Expert

Re: prevent users from adding items during a specific time

Jump to solution

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.

Reply
rencygonzalez
Novice

Re: prevent users from adding items during a specific time

Jump to solution

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 ?

0 Kudos
Reply
jesse_mchargue
Nintex Workflow Cloud Expert
Nintex Workflow Cloud Expert

Re: prevent users from adding items during a specific time

Jump to solution

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:

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

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:

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:

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!

0 Kudos
Reply
xMikeX
Scholar

Re: prevent users from adding items during a specific time

Jump to solution

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

Reply
rencygonzalez
Novice

Re: prevent users from adding items during a specific time

Jump to solution

Thank you so much Mike

0 Kudos
Reply
rencygonzalez
Novice

Re: prevent users from adding items during a specific time

Jump to solution

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

0 Kudos
Reply
rencygonzalez
Novice

Re: prevent users from adding items during a specific time

Jump to solution

Hi Jesse

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

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.

0 Kudos
Reply
jesse_mchargue
Nintex Workflow Cloud Expert
Nintex Workflow Cloud Expert

Re: prevent users from adding items during a specific time

Jump to solution

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

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 ) and it goes through:

within window:

before window:

after window:

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!

0 Kudos
Reply