Scheduling jobs based on date in data?

This might be outside of the scope of PlanetPress but I thought I’d ask just in case. Is there any way of getting a Workflow process to pick up a date in the input data and pause the process until that date?

Specifically, I want to send emails on the date that is on the letter on the PDF attachment. As emails send immediately when the relevant process is triggered, I was hoping to find a way to start up the process but the emails would filter through on the dates on which the documents are dated.

If this is possible, I would also like to be able to set the time of day at which the email is sent (e.g. noon) because no one wants their emails to start beeping at midnight!

Regards,
Lisa

Here’s one possible way of doing things:

Have a process that simply performs data mapping. Make sure you extract the target date in your data mapping configuration.This process should run all the time (i.e. whenever a new email needs to be prepared) since all it does is prepare and store the data in the database.

Then, create a process whose Schedule is set to run every day at noon. Start that process with a Create File input task, the data is actually irrelevant.

In that process, add a Retrieve Items task to fetch Data Records whose Date field is equal to today’s date (you can use a combination of the %m/%d/%y system variables to build the proper string format). So if 10 records have that date, then only those 10 records will be retrieved.

You then call the Create Email Content task and only those records will be processed and sent.

That sounds like that could work, one problem I’ve had on testing it out though is that I’ve found after it will find the first relevant record and then send it over and over again until I stop the process. If the process is started again, it will go back to sending that same record over and over again, even if I haven’t put anything new through the datamapper. Is there a step I’ve missed out that will get it to progress to the next valid record, or clear ones it’s already processed?

… Additionally, I’m stuggling to figure out how to get the Retrieve Items task to recognise my date field (I’ve been testing it on a string field and that picks up fine, except of course for the whole getting-stuck-on-one-record issue). I’ve tried a bunch of different combinations with the % indicators but I’m probably using them wrong - the input data would be formatted 05-Aug-16 and it’s converted to a date in the datamapper, where it shows the converted data as 05/08/2016 00:00. So I’ve been asking it to pick up values like %d-%M-%y and also %d/%m/%Y 00:00 but those and variations I’ve tried of those haven’t worked so far. I’ve also tried getting it to just pick up the exact values 05-Aug-16, 05/08/2016 and 05/08/2016 00:00 but no luck. What am I doing wrong?

OK, I admit I wasn’t thorough enough in my explanation.

The reason why your second process keeps sending your emails again and again is because its Schedule isn’t set to “Poll once per activity period”. Therefore, it keeps running all day. If you tick that option, it will run once, then wait for the next period before being launched again (which will be tomorrow). See http://help.objectiflune.com/en/pres-workflow-user-guide/8.4/Default.html#cshid=5020 for more information.

Now as far as the date is concerned, you’re right: it’s difficult to get an exact match when comparing date types because Connect stores them as actual Universal DateTime values (e.g. 2016-08-05T04:00Z?, which reflects the fact that I’m 4 hours behind GMT here). We are currently working on making these types of conversions easier. In the meantime, you should either set the date as a String in the DataMapper or add another field to your datamodel that extracts the exact same value as a String and then use that new field in the Retrieve Items task.

Excellent, that seems to be working now, thank you! Is there a tag for the truncated version of the current year (i.e. ‘16’ instead of '2016)? I’ve currently got it to work by comparing the string version of the date to %d-%L-16 as %y and %Y don’t seem to work, although it wouldn’t be the worst thing in the world if we had to just update the process once a year.

I tested this over the weekend and we do a weekly restart of the servers on a Saturday evening - the Saturday emails sent at the correct date and time but the Sunday emails did not get sent at all so it appears that a restart will wipe all processed data. Which makes sense and we can work around that (only processing data for the week up to a Saturday night, then sending the next week’s data on the Monday), but just in case I’m missing something, is there a way to get the database to save data more permanently? I’m a bit mystified by the OL database in general, really, as there doesn’t seem to be any way of accessing or manipulating it, you just seem to send data and then you can’t see it but it all just sits there waiting for the right process to drag it out.

For a 2-digit year, insert a Mathematical Operations task just before the Retrieve Items task. Set the Mathematical Expression field to %y-2000 and the Store result in field to 9.

This will store the value 16 in JobInfo 9. Then, in the Retrieve Items task, use the expression %d-%L-%9.

As for the Database, it gets cleaned up automatically according to the Schedule defined in the Connect Server Configuration tool’s Clean-up Service section. By default, it also runs at application startup (which is user-configurable), so that explains why your data gets wiped on Saturday evenings after you restart the services.

Perfect! Thank you so much for your help.