Condition on Scheduled Job not working as intended Please Help!

Not applicable

I have the following Scheduled job.  It should run on the second monday of each month.  If I take the conditional code and run it in scripts background (and replace with return with gs.print('true') or gs.print('false') respectively). I get the correct response, with true or false.  These should run every monday of the month due to having multiple jobs that have the same criteria of 1st, 2nd, 3rd, 4th mondays (each monday will run a different job).  If I execute from the UI Action button it runs.  If I set a time for like 15 minutes in the future on the given date it runs.  However it does not run as it should.  Please help!  Am I doing something wrong with the condition?  It's hard to troubleshoot this as it's only running the x number monday of the month.

Here is the scheduled Job
Conditional.jpeg

johnfeist
Mega Sage

Hi Stephen,

I'm assuming that you have defined the Date object somewhere.  One thing that I notice is that in your condition, the first criteria is new Date().getDay() while the two other criteria are using new Date().getDate();  I'll assume that all three criteria are simply looking to give you an evaluation of the current day of the month.  Perhaps if you have a step before the criteria evaluatisns:

var dateNum = new Date().getDay();

and then evaluate your criteria against dateNum, that will clear your issue.

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Arpan Baishya
Kilo Sage

Hi @Community Alums,

 

If I am to go by what this thread says, it could be a case of a mismatch between time zones. Check the value for the Time zone field for this record. According to the value you see, you may need to check if the scheduled job ran at that particular time or not.

 

To know how to check for scheduled job execution history, click here.

 

Hope this helps.

Not applicable

Interesting @Arpan Baishya  I did not see either field filled in.  So I have adjusted with a test instance and will see what happens tomorrow.  I should get the job to run at the time it should be now.  I'll mark as Solution accepted after test.

@Community Alums I thought of checking with you if the schedule job ran as expected.