Configuring a Workflow to send an alert when days have elapsed

  • 8 November 2017
  • 54 replies
  • 103 views

Badge +10

I need to send an email alert if 7 days have gone by since a date was entered in a field called 'Start Date'.

In the Calculate Date field I've  got the Date as 'Workflow Context' and then 'Current Date' I've set up a variable called CheckDate which is where the information is stored. I've set the Days to '1'.

On the Query List I've set the Filter to 'Start Date' is equal to CheckDate.  I've go the output to 'CheckDate' (I don't think this is right?)

The idea is that I compare the Start Date to the 'CheckDate' and as soon as it hits todays day + 1 an alert I sent out.

Full Date Workflow

This is how I've configured the 'Set a condition' action but I'm pretty sure I've got it wrong...

Can anyone nudge me in the right direction?

DatewORKFLOW


54 replies

Userlevel 5
Badge +14

single line text

Badge +10

Cheers, yes set that up as such in the meantime.

I'm setting the Coll_IDs variable as a List Item ID then the For Each Action like this:

and then when I come to the Collection operation action it's giving me the CollectedHRDates as the Target Collection but no options under the Index drop down?

Userlevel 5
Badge +14

you have to create a numeric variable to be used as an collection index happy.png

Badge +10

Thanks! I'll give it a whirl and let you know what happens!

Badge +10

I didn't get any notification at all this time?

Userlevel 5
Badge +14

your query list action likely didn't return any items ...

Badge +10

Right, this is what I have in the CAML editor:

<Query>
  <Lists>
    <List ID="{15E889B2-D646-46CE-9D8B-D7F13364C7F3}" />
  </Lists>
  <ViewFields>
    <FieldRef Name="Last_x0020_Name" />
  </ViewFields>
  <Where>
    <Eq>
      <FieldRef Name="StartDate"  />
      <Value Type="DateTime" IncludeTimeValue="True">{WorkflowVariable:InputDatePlus20min}</Value>
    </Eq>
  </Where>
</Query>

Could it be the  <FieldRef Name="Last_x0020_Name" /> line?

Userlevel 5
Badge +14

no, that's correct I think.

but you have changed comparison operator to Equal.

as far as I can see from your previous screenshots, your StartDate field is configured to hold just dates without time. with CAML above you request to compare including times. so you effectively compare some time value within the day against the midnight. and that very likely do not match any item.

Badge +10

Thanks again for all your help Marian I really appreciate it.

I was getting an error on the workflow so I deleted the Query action and set it up again with adding the extra code in the CAML editor. I'm now not getting an alert at all but the workflow is showing that it's completed. I think you're right. I think it's not finding any results cause of the time. The only reason I've set it as a 20 minute increment is for testing purposes (eventually when I get this working it'll be a 7 day alert) . I don't want to wait a day to see if the workflow works, I think it's down to the time element. So if I was to change the Start Date to a Date and Time field on the InfoPath form would that show results (I'm going to try it) or is there a way that if I change the Calculate date action to value days 1 than I can test it immediately?

Badge +10

No, still not getting anything. This is what I've got in my CAML editor:

<Query>
  <Lists>
    <List ID="{15E889B2-D646-46CE-9D8B-D7F13364C7F3}" />
  </Lists>
  <ViewFields>
    <FieldRef Name="ID" />
  </ViewFields>
  <Where>
    <Eq>
      <FieldRef Name="Dateand_x0020_Time"  />
      <Value Type="DateTime" IncludeTimeValue="True">{WorkflowVariable:InputDatePlus20min}</Value>
    </Eq>
  </Where>
</Query>

Userlevel 5
Badge +14

what's the InputDatePlus20min value you supply to the CAML at runtime?

based on your list data screenshot from above I believe following query

<Query>
  <Lists>
    <List ID="{15E889B2-D646-46CE-9D8B-D7F13364C7F3}" />
  </Lists>
  <ViewFields>
    <FieldRef Name="ID" />
  </ViewFields>
  <Where>
    <Eq>
      <FieldRef Name="Dateand_x0020_Time"  />
      <Value Type="DateTime" IncludeTimeValue="True">2017-11-14T00:00:00</Value>
    </Eq>
  </Where>
</Query>

should return two items - Baker and Davison

Badge +10

It's this below. Does it matter that the Baker and Davison items don't have the Time input on the form?

Badge +10

I've replaced the {workflow variable..} with 2017-11-14T00:00:00 in the CAMeditor to see what it does.

Badge +10

No didn't get anything and the Workflow History is saying that the workflow completed.

Userlevel 5
Badge +14

I meant what's the value of InputDatePlus20min variable  after calculate date action - you have to write it to history log and check it there.

Userlevel 5
Badge +14

can you try the same CAML without IncludeTimeValue clause?

just right now I've spot you compare "Dateand_x0020_Time" field in recent CAML, but before you compared "StartDate".

so, what's the field you want to actually compare to?

Badge +10

I thought the time might be an issue so I added a field to the form called DateandTime where the time could be input.

I looked at the history and got this. Does it mean that it's not getting to the Collection Operation action?

 hISTORY

Badge +10

This is the For Each

Badge +10

I've taken IncludeTimeValue  out to see what that'll do.

Userlevel 5
Badge +12

Those actions are not being executed (they almost appear to be disabled but that just might be the screen shot).  What is happening is there are no items in your collection.   Check the index size of your CollectedHRDates.....    Oh by the way it looks like you areusing CollectedHRDates and then storing it into a variable called Coll_IDs... this may just be your naming convention, but Coll_IDs should really be a string variable that is storing the ID of the current item.    CollectedHRDates is full of the item IDs correct?

Badge +10

Cheers. How would I check the index size of CollectedHRDates? So you're saying Mike that nothing's been stored in the CollectedHRDates Collection so that's why the actions aren't being executed?

On the For each action I'm targeting the CollectedHRDates and storing them in the Coll-IDs list item I

Should I be storing some earlier results in CollectedHRDates?

Badge +10

I've been following ‌ steps from yesterday and I can see that she's set up a collection variable called Coll_IDs (which is CollectedHRDates in my workflow) and it doesn't look that that variable is used earlier in Workflow?

Userlevel 5
Badge +12

Hi Darren,

Right - if the collection is  empty the foreach won't execute because it has nothing to loop over.   Check your Query List action - something inside of Query List action.   Most likely it is the value of your dates not matching what it expects.   Question - do you care about the time portion of the date or merely want to retrieve items after X amount of days?

Thanks,
Mike

Userlevel 5
Badge +14

let's start over from the step by step example I posted above.

I've shown you how to configure what action and where to use which variable. but you seem to again fallen to your former wrong settings.

as well, it seems you did some changes and tests out of the recommendations provided, but reported them back as if recommendations were wrong. to be honest, I'm lost right now what is your current workflow setup, list configuration, list content, etc.

so please review carefully that post once again and configure the workflow by that.

if you still do not get it working, post configuration of each of your actions, configuration of involved list fields and current sample data from your list.

hope that will bring us back on track.

and not to forget, as Mike Matsako pointed out, you have for any reasons  disabled collection operation and send notification actions within the loop. despite not executed, they should by drawn with colored icons but without green highlighting.

go to the designer, click the arrow icon on the top right of each action and enable them

Badge +10

Hi Marian

Thanks for your patience! Just took another look and suddenly saw what you said about the equals rather than the greater than! Corrected it, but no luck. I think I've got what you posted, but I'll go through it now in case. ‌, yes the time isn't important, I'm just using that s a test, the date and how many days has elapsed is the important one.

Stage one - Calculate date - the InputDatePlus20min variable is a single line of text

CalculateDate

Stage two - Query list - the CollectedCheckDate variable is a collection

Query List

Stage three -  CollectedHRDates is a collection (it's the only collection ableto access on the drop down) varCurrTitle is a single line of text and idx is a number

For Each

Stage four - Collection operation

Collection Opertion

Stage five - send notification - a bit of a scatter gun to see what comes out, so far nothing has!

Reply