0

I am trying to schedule a job to run on thursday and saturday for testing purposes.

I researched and found several documents about how to do this but when implementing this in salesforce it is giving me errors. Is this function not supported or does salesforce have their own syntax for this?

According to http://www.cronmaker.com/ the syntax should be:

0 0 12 ? * THU,SAT *.

When I try this it gives me error Illegal characters for this position: 'SAT'

Another article said to replace the days with numbers corresponding to the day of the week. So I tried:

0 0 12 ? * 5,7 *

This gives me error Based on configured schedule, the given trigger will never fire.

I have also tried without the ending * for both.

0

Both of your syntaxes are correct according to the Salesforce documentation here https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm. In fact, I tested your syntax and it worked.

Are you scheduling it according to the following convention System.schedule('JOB NAME', 'CRON SYNTAX STRING', new SchedulableApexClass())?

3
  • Yes i have tested with other cron schedules and everything works fine. Only when i try with this does it give error
    – theNewGuy
    Mar 11 at 17:05
  • Are you scheduling apex classes? I just tested your syntax and it worked fine. Maybe there is a hidden character in your cron syntax? Mar 11 at 17:09
  • I think this is a weird issue. I was able to get it working. I am using a custom object for scheduling emails and i have a multiselect picklist with the days in it. In the apex class i had a map that was converting the days into cron days(So monday would be '2' or 'Mon' in the map). I got rid of this map and instead changed the api name in the multi select picklist to 'Mon' for Monday and so on, and now it works fine. Its the same exact text I had in the map though so not sure. Maybe there was hidden characters as you said.
    – theNewGuy
    Mar 11 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.