Workflow retrieved context last run value is wrong

Hi everyone,

I am currently using a workflow with a scheduled trigger. In the first step, I retrieve the last run value from the context and then use that value to filter my database.

The problem arises in the morning when I attempt to retrieve the last run. Instead of receiving the value from the previous day in the evening, I receive the value of the current time minus one hour.

Below is the code I used:

const lastWorkflowRun = workflowContext.lastRun.startedAtEpochMs;
const lastWorkflowRunDate = new Date(0);
lastWorkflowRunDate.setUTCMilliseconds(lastWorkflowRun);
const startDate = lastWorkflowRunDate.toISOString();
console.log('START DATE: ', startDate);
return startDate;

Any thoughts on this? Is there something wrong with my code?
Thanks

:wave: @dandpz if you're still running into this, as a troubleshooting step you can console log the workflowContext.lastRun.startedAtEpochMs value to make sure it's what is expected. Otherwise it'd likely be a configuration issue somewhere in the code. :thinking:

Actually, I've already tried to log that value and convert it to a timestamp, but it yields the incorrect value. For now, I've implemented an inelegant workaround to keep the flow functioning: I simply check the digits within the timestamp. Given what I know about the schedule, this approach works, but it relies on a very crude 'if' condition that I'm not proud of.

Hey @dandpz! Looks like we did some work on this and you should be getting the correct value now. Looks like it's working for me, but can you test that out again and let me know if you are getting the proper start time with the startedAtEpochMs value?