cancel
Showing results for 
Search instead for 
Did you mean: 
Patrick_Sweeney
Star Contributor
Star Contributor

There has been demand recently for running Unity Scripts on a periodic basis, independent of a specific action. Reindexing documents at a set time, searching for new items to process on a daily basis, or even performing operations on only a select few days of the year are all circumstances customers have expressed interest in. Previously there wasn't a simple way to do this. Users could pursue workarounds using the Workflow Timer Service. However that kind of workaround requires Workflow and special lifecycles/queues, isn't intuitive, and overloads the Workflow timer service with functions that don't necessarily have anything to do with Workflow.

To that end we're very happy to introduce a featue often requested by customers: the Unity Scheduler and the ISchedulableScript. With these tools users will be able to create familiar Unity Scripts in OnBase Studio and schedule them to run via a dedicated timer service.

Implementation

Using the Unity Scheduler is basically a three step process.

First the Unity Scheduler pieces must be installed. These pieces include the Unity Scheduler directory and install files, the Unity Scheduler timer service, and the Hyland Unity Management Console. You can find a more detailed guide to the installation and use of these components in the Unity Scheduler MRG, found here. During this step you should also follow the MRG's instructions for creating a new instance of the Hyland Unity Schedule Timer Service. Care should be taken to note that creation of this timer service does not happen automatically during the install and will require a command entered via the command prompt. This design decision was made to allow users to create and manage multiple Unity Scheduler service instances simultaneously on the same system.

Secondly a script must be created in OnBase Studio using the ISchedulableScript interface. This is a typical Unity script and should be written just as any other Unity script. One thing to note is that, despite being a schedulable script, the script itself has no notion of time or a schedule. It is the other pieces, the timer service and the Hyland Unity Management Console, that place the script in a schedule context and execute the code at periodic intervals.

Lastly the Hyland Unity Management Console brings the timer service and the ISchedulableScript together. The management console allows the user to define schedules and then associate ISchedulableScripts with those schedules. Then, naturally, the timer service runs the script at the scheduled times.

Example

Let's go over an example!

Following the MRG let's assume that the installation went alright and we have to install an instance of the Hyland Unity Timer Service. Using the MRG we might create a timer service like this:

C:\Program Files\[Hyland Unity Scheduler directory]\Hyland.Core.Scheduler.NTService.exe /create -sn=[Timer Service Name] -obu=[Service Account name] -obd=[ODBC name]

Just to put in some values let's say we use the following: [Timer Service Name] = "Hyland Unity Scheduler 01", [Service Account name] = "Service", and [ODBC name] = "9 Second Foods". The timer service should be available in our services listing now. You can access the service listings either through Administrative Tools -> Services or by searching for and running services.msc. Services.msc can also be access from the command line. Once the services window is open we'll make sure that our service exists and is properly started.

The next step is to create an ISchedulableScript:

An ISchedulableScript is very basic type of script that is only meant to be used in conjuction with the Hyland Unity Scheduler. It is created in OnBase Studio like any other script. Like a Global Client script or a Workflow script the ISchedulableScript does not need any associated context like a Document Type to function. Once we've added code, published, and made active the script we can move on to actually scheduling it.

Scheduling is done via the Hyland Unity Management Console. Opening the management console and clicking on the "Add" drop down allows us to add a Task Scheduler.

To schedule a task we need to choose the "Create Task" action. This can be seen on the rightmost window, but it can also be accessed from the Action menu or by right clicking on the Task heading in the tree view on the left. Adding a task first involves selecting a previously created ISchedulableScript. I previously created one called "Scheduler" and so I would select it now:

Next we can specify what kind of schedule we want to run the script on. These schedules can be created at the time of creating this task or we can use schedules created independently of tasks. The advantage of creating schedules outside of the task creation process is that we can reuse schedules in multiple task configurations. If we wanted to do that we could choose the "Create Schedule" action before choosing the "Create Task" action. But we're creating a task right now so we'll add a couple of ad-hoc chosen times to run the task directly. Tasks can be run at an interval ranging from minutes to days, weekly, monthly, monthly (day-relative), annually, or only on specifically chosen dates with no recurrence.  I highly recommend viewing the MRG for the Unity Scheduler to fully grasp what options are available when using the management console to schedule tasks. There's simply too many options to go into depth on all of them here!

To make things simpler we'll schedule our script to run just two ways: on the second Tuesday of every month at 6 PM and every Saturday at 2:00 AM.

After the schedule is set we're prompted to specify when the task begins and ends.  We'll set it to run only for the final week of 2016:

And that's it! The Unity Scheduler service should execute our ISchedulableScript at the scheduled times!

Conclusion

The Hyland Unity Scheduler and the ISchedulableScript should be powerful tools for automating your custom processes without having to resort to workarounds with Workflow or the Windows Task Scheduler. We hope that you find the tools intuitive to use and flexible enough to accommodate your business solution.

Join us next week..