Filtering a query based on an instance variable

Avatar

Avatar

matt-gardner

Avatar

matt-gardner

matt-gardner

24-07-2017

In my workflow I am populating an instance variable with the last run date:

instance.vars.last_run_date = new Date()

Each time this workflow runs it populates the variable. 

My question is - how do I use this variable in a query node target selection - I want to only pull back records where the expression modification date > instance.vars.last_run_date is true.

I cannot find examples of how to do this. Any pointers would be super helpful.

Cheers,

Matt

View Entire Topic

Avatar

Avatar

matt-gardner

Avatar

matt-gardner

matt-gardner

26-07-2017

Thanks for input.  We did try the incremental query but in Adobe Campaign 7 it is not possible to get new and modified records via an incremental query.

In the end I created a workflow with a javascript node that read a last_run_date from a file and captured the current date-time - both values were written to instance vars to be used in later steps in the workflow:

// Get last_run_date from file

var f = new File("/path/last_run_date.txt");

f.open("r");

var line = f.readln();

f.close();

instance.vars.last_run_date = line;

// Store time process started

instance.vars.current_run_date = formatDate(new Date(), "%4Y-%2M-%2D %2H:%2N:%2S");

logInfo("Read last_run_date from file = " + instance.vars.last_run_date)

In the query node I could add a targetting rule to filter the table for records with a modification date on or after $(instance/vars/@last_run_date).

Finally after the query had executed I wrote the last_run_date back to disk in another javascript node:

var f = new File("/path/last_run_date.txt");

f.open("w");

f.write(instance.vars.current_run_date);

f.close();

logInfo("Saved current run date = " + instance.vars.current_run_date);

Seems a bit clunky but works!  I imagine there is a better way to avoid the use of an external file to store the last run date between runs of the workflow.