Scheduling your Salescast executions

Published on by Joannes Vermorel.

Update 2015-02-10: we have now a built-in WebCron integration which is now the approach we recommend as it is more secure.

Inventory optimization should be business as usual. Yet, Salescast, our inventory forecasting app, does not natively support scheduled executions yet. However, it is possible to obtain scheduled executions with 15min setup. In order to do that, we are going to combine the API of Salescast which offers a programmatic control on Salescast with webcron service.

A webcron is a generic name to refer to an app that behaves like an online task scheduler. If you look for webcron on your favorite search engine, you will get plently of software companies who support such a service. In this post, we will use setcronjob.com that comes with a free subscription plan (as of January 2015) vastly sufficient for our need.

Thus, in order to get daily or weekly execution of Salescast, you should start by creating an account on setcronjob.com. Once, you have your SetCronJob account, go to the Users page whithin your Lokad account, and then click on then Add user button. Creating a distinct Lokad user dedicated to the webcron is important for security purposes. Lokad will offer you two options, click Enter Username and Passwordand proceed. Then you can create a new user with:

  • SetCronJob Robot for the full name
  • setcronjob@example.com for the login. You should replace example with the actual domain name of your company. It does not matter if the email address does not actual exists.
  • a long random password. Just stick to number and letters for simplicity, but make the password long (say 20 characters long). You won't have to actually every type this password, so keeping it short and practical is irrelevant.

Click Add user, and now that you have created a dedicated Lokad user, go back to setcronjob.com and log into your account. Here click Create CronJob. In the field Url to call, enter the following URL (detailed below):

https://setcronjob%40example.com:pwd@salescast2.lokad.com/rest/basicstartrun?folder=fld

Finally pick Every day or Every week in SetCronJob to run Salescast with the desired frequency. You can also adjust the actual time of the day when Salescast will be run if you click the More options button.

Composing this URL is a bit tricky, let's have a look at the detail. The first part is setcronjob%40example.com. Notice that the @ sign of the email address has been replaced by %40. It's because characters in the URL needs to be URL-encoded. In practice, latin letters and numbers remain the same, but more advance characters like the @ are replaced by their encoded counterparts.

The second part that comes after the semicolon (:) is pwd. Replace this part with your actual password. If your password is just letters and numbers as suggested above, then the password does not need any special URL-encoding treatment, so cut-and-paste should work just fine.

Finally, the last part fld should be replaced with the output folder of your Salescast project. The output folder is displayed in your Salescast page. If your Salescast project is loading its files from the root folder, then your URL should just end with ?folder= (with nothing after the = sign).

Once you have finalized your CronJob, just run it once to make sure it's working. You should be able to see Salescast running in your Lokad account.

You're done. Congratulations! From now on, Salescast will be executed according the schedule.

Caveat: SetCronJob let you pick executing frequencies like Every minute; yet make sure not to pick a for Salescast that is shorter than 1 execution per day, as this would most likely result having your Lokad account put on hold. If this were to happen, just mail us at contact@lokad.com and we will help you restore the access to your Lokad acccount.

Categories: Tags: salescast technical