I've set the Days to 1 for test purposes...
I want to clarify what you're asking. You said "I need to send an email alert if 7 days have gone by since a date was entered in a field called 'Start Date'."
If I take your wording exactly as you wrote it, the date that is entered in the field 'Start Date' is irrelevant - you just need to know if 7 days have elapsed since any date was entered there, is that correct?
If that's the case, one way is to trigger the workflow to start conditionally on item modify when 'Start Date(previous value)' not equals 'Start Date')
Save the 'Start Date' to a variable (varDate1), a "Pause" action for 7 days, then Run if varDate1 equals 'Start Date' with a notification in the 'Run if' action.
Hi. No sorry I should have been more clear. What needs to happen is that the user enters a date in the 'Start Date' field and seven days after that entered date an alert is sent out. So if I enter '13th of November' in the Start Date field that an alert is sent out on the 20th of November.
In that case, this one should be easy.
Start workflow on modify with the condition that 'Start Date(previous value)' not equals 'Start Date'. This ensures the flow will only start when the Start Date field is modified.
(If the Start Date field is filled in on the initial item creation, you'll want to start this differently)
Use calculate date > List Lookup > (Source) Current item > (Field) Start Date
Then in the "Days" field , value should be 7. This adds 7 days to Start Date.
Store Date in varDate1 (Date and Time variable).
From here there are a few ways you can finish this, but I like using a "Pause until..." (Workflow data > varDate1) action followed by a notification action.
Keep in mind that if you do it this way, if Start Date is changed multiple times, it won't affect the first run of the workflow, e.g. if Start Date is changed to Nov 13, an alert will be sent on Nov 20 regardless of the fact that the Start Date was changed on Nov 15. Another alert will not be sent.
OR
Create a new Column called "Alert will be sent on" and make it a Calculated column. In the Formula box put pStart Date]+7 and the data type returned will be Date and Time (format: Date only).
You can hide this column from the list view if you like. This new field will dynamically update whenever the Start Date field is changed.
Create a new workflow that will start on modify and use a Pause Until... action > (Source) Current item > (Field) 'Alert will be sent on', and a notification action after that.
You'll want to test this because I'm not sure if the Pause until action will read an updated value or if it will keep the initial value.
better then let the workflow running and waiting for some specific date or time elapsed, is to design a site workflow and schedule it to run daily.
the workflow then checks for which items a notification should be sent out on 'today'
see an example on Cassy Freeman's blog -
Thanks Marian, Cassy's blog worked like a dream!
Actually one question, how do I get it to stop once it's sent out one alert?
I wish Nintex had a way to specify a workflow as "Only run this once per item" but it doesn't.
You'll have to add a column "Has this workflow run yet" with a yes/no value, set default to No and flip it to Yes when the workflow runs, and add a run if action to only run the flow if the workflow has not run yet.
I actually use this on my own site, it will not work without a little regexing. Because when you capture the date value in a variable it captures the TIME value as well, you will have to use regex to strip the time value from the date.
e.g. if you set Start Date to 10/3/2017 and capture that in a variable the value looks like this:
10/3/2017 12:00 AM
But when you compare it to a date column to try and match it, the value looks like this:
10/3/2017
and it won't match it ( because your site flow isn't running on all items exactly at 12:00AM) and send the note.
Capturing the date field in a variable appends the time EVEN IF you specified that the column with the date is DATE ONLY.
I'm not sure what you mean.
do you want to send a notification just for first item found?
then you you can define a stop condition for 'for each loop' or do not use a loop at all.
or you mean one notification for an item?
if a workflow is scheduled just once per day, date condition should be met just on one specific date, so just one notification should be sent.
or any other requirement?
I've never taken care of date part if I haven't needed time-precise comparison.
CAML by default makes comparison just on date level. you have to explicitly request it to make time-precise comparison.
however, I never supply date-type variable to query list action and/or CAML itself. I always supply ISO formatted date string. date-type variable never worked reliably for me in multi locale environment.
I've noticed that the Site Workflow on the date alert is only sending out an alert for the first item. where could I be going wrong?
Hello,
You'll need to loop through the collection of items that you obtained from the Query List action - if you do not have the return variable set as a collection then you might only be getting back one response. Double check that and see how many items you have. Also make sure that more items meet your criteria for which you are checking other than the single row.
Thanks
Mike
hm, now I'm confused.
above you've asked for a way how to send out just one/first notification. now you object that it works that way and sends only one notification.
what exactly are you trying to achieve?
I'm now getting a Workflow Error. The error is on the For Each Action.
I'm using the CollectedHRDates Collection variable earlier in the Workflow to collect the initial return from the start date
form. Should I use a different Collection variable for the For each Action?
This is how I've configured the For Each and subsequent Query actions.
How I understood it would work was that the For Each would target the Collection where the Start Dates are be stored, the saved to another variable called foreachcollectedstarttimes (which is a Date variable).
The Query action is configured to check that the Start Date is equal to CheckDate (which is the variable I've set up for the Calculate date action, then in the Output it's saving the Start Date in the CollectedHRDates.
So where have I gone wrong? Do I need more Collection variables and need to use them at different points?
Hi Darren,
What's the workflow error that you are getting?
Thanks
I don't know how helpful this will be Mike but it's showing an error at the For each stage
Hi Darren,
Not the most verbose error now is it... My suggestion to loop on the item ID collection and use an index set in the for each action in combination with a Collection Operation of "get" to pull the date and then do the compare. You can log the date to make sure you are getting it back in the expected format to make your comparison.
By having the item IDs in a separate collection (the one you loop through with the for each action) you will be able to use the id to update the item's status or do whatever you want to the item in the source list knowing which item you need to target. You can also make sure you are getting back the set of expected values (log the ID collection out to see which items you are getting back) to make sure they match up with the ones you'd expect your Query Lists action to return (these are the ones that meet your criteria).
Thanks,
Mike
Darren,
I'm affraid, you over-complicated the things, or somehow missed the point how notification site workflow should work.
I would recommend to study and follow Cassy's blog once again.
what's the problem with your setup?
your first query list action retrieves item IDs(!) that meet the condition StartDate == CheckDate. and stores them into (hopefully) collection variable 'CollectedHRDates'
then you set up a for each loop that iterates over this collection variable.
within the loop you perform logically just the same query list action, with only difference that it returns now StartDates instead of IDs. you store the result set to the same variable 'CollectedHRDates'.
first of all, the later query list action (one within the for each loop) overwrites 'CollectedHRDates' variable, which is driving variable of for each loop itself. not to surprise it causes error once next loop iteration is to be entered.
for the second, I do not see a reason for making the same query twice.
you could query for StartDates with first query action already. then within the loop pick the date from current collection element and use it as needed - eg. send it within the notification.
if you for any reasons need to do it in two steps - first to query for IDs and then by a given ID retrieve rest of the list fields (eg. StartDate) - then the second query action should have been filtered by an ID from first query (current collection element from for each loop iteration).
I think I'm lurching towards a resolution to this! Thanks for all the help! What I'm getting now is an alert on the first library item and then the Workflow errors at the For Each action.
I've set the For Each Action like this:
and the Query List action to this:
My reasoning is this:
1 In an earlier Query List action I query the StartersandLeavers library
2 Filter the results when Start Date is equal to Check Date (the variable where the Calculate Date results are stored)
3 In Output select the Start Date field and save the results to the CollectedHRDates Collection variable.
4. For Each action (as pictured). Target the Collected HRDates collection and store the results in foreachcollectedstarttimes Date and Time Variable.
5. Query List action (as pictured) the list is StartersandLeavers.
6. Filter Start Date is equal to CollectedHRDates
7 Output, Field Start Date to CollectedHRDates (do I need to create another variable to store the results? If so should it be a date and time or collection variable)
The desired result is that an email alert is sent out for every item in the list which now has a start date 20 minutes+ from the original input start date.
What do I need to tweak?
Actually reading over your answer I've disabled the first Query List action and I'm letting the Query List in the Loop do the work to see what that'll do...
6. Filter Start Date is equal to CollectedHRDates
this is not going to work.
you can not compare whole collection, you should rather compare single collection elements. so you likely should compare to 'foreachcollectedstarttimes' variable.
as I tried to explain above, I would say your workflow should simply look like this
so, first add 20mins to the InputDate
next, query list for all items which's StartDate is greater then calculated InputDate +20mins. (I used greater then, since you mentioned "20 minutes +")
since you want to compare including time ("20 minutes +") you can not simply configure query with query builder, since it by default setup the query that compares just dates.
to make it easier, you can start configuring the query within builder and setup the base structure ...
but then you will need to switch to CAML editor to manually add IncludeTimeValue="True" clause.
configure the query to return all the fields that you will later need in send notification action (ID and Title in my example). store each result set into separate collection variable.
then you simply need to iterate over one of the returned collections with for each loop action
possibly pick values from the other returned collections
finally send a notification with collected values
and you're done
This is a nicely drawn out picture of what I explained above. Thanks for taking the time to screen shoot it all
The concepts break down to this:
1) You will want a single Query List action to gather your collections.
2) You will loop over this collection of IDs to act on each row that needs acted upon.
Important point: You do not want to use Query List inside of your Foreach loop as that causes more traffic than necessary since you will already have your collections obtained from a single query list.
I know this may seem complicated but once you get the concept, it becomes much easier. Use logging during your development to check your values - you can always remove it latter.
What you are doing is Querying to get your result set, looping over your result set, and performing an action on the items that need acted upon.
Thanks
Thanks both, I'll give it a go...
What should the InputDate +20mins variable be? I've set it as a Date Variable but then it's not showing in the Store ISO 8601 date string Field?