Easily Get Current Date Using CloudWorks

Almost any model builder has had to come up with a solution to get the current date in Anaplan. We used to build integrations and use API for that. @JaredDolich posted a great article about using python for getting today's date.

But this approach has some cons:

  • You must learn to code or involve someone who can do it. Both options are time-consuming and sometimes require an extra budget.
  • Because we rely on an external system, it brings extra chances of failure (both Anaplan outages and server outages will cause a failure).
  • You'll likely require someone to support it once it's running.

But now this can be done by any model builder, without external systems and coding. It will take only 30-60 minutes of your time and no coding to set it up—with CloudWorks. 

How To Do It

The idea is to use CloudWorks to run a process that adds up +1 day to line item with date, but we'll also see how it can be made more reliable. This method will save us from Anaplan maintenance or downtime. If they take place at the scheduled time, we'll be protected.

STEP 1: 

Create a module with a dummy item (dummy item will help to set up import action). The screenshot below shows a blueprint of the module.



MAIN date - current date, the value is imported from MAIN date + 1 on a scheduled basis via CloudWorks.

MAIN date + 1 - formula adds +1 day to MAIN date line item. It also checks if the last run of MAIN process has failed. If so, it adds up +2 days to MAIN date, so we get back to the correct date.

MAIN last run failed? - checking if the last scheduled run of MAIN process has failed. If BACKUP date is greater than MAIN date, we understand that MAIN run has failed (because we schedule MAIN process to run first, before BACKUP).

BACKUP date - same as main, but works as a backup and is imported from BACKUP date + 1

BACKUP date + 1 - formula adds +1 day to BACKUP date line item. It also checks if last run of BACKUP process failed. If so, it adds up +2 days to BACKUP date to correct itself.

BACKUP last run failed? - checking if the last scheduled run of BACKUP process has failed. We do it by comparing the difference between backup and main dates. It shouldn't be more than 1 day. If so, it means the last run of the backup process has failed.

Current date final - takes maximum between MAIN and BACKUP dates, so if one of them has failed, current date final will be correct.

STEP 2: 

Set up two views where only MAIN date + 1 and BACKUP date + 1 line items are visible. Use these views to set up import of date from MAIN date + 1 into MAIN date and BACKUP date + 1 into BACKUP date respectively. Both imports then should be included in separate processes, so we can schedule them with CloudWorks.




Schedule main and backup CloudWorks processes. I scheduled main for 00:30 AM and backup for 6:00 AM local time (Anaplan maintenance usually takes four hours). You can learn how to set up CloudWorks integration here.



You'll need to manually input the correct MAIN date and BACKUP date for the first time. Going forward the process takes care of it.

That's it! You now have a current date in a model, which is protected from outages and maintenances.