You are viewing limited content. For full access, please sign in.

Question

Question

Schedule workflow to run on Aug 1 every other year

asked on July 2, 2019

What is the best way to schedule a workflow to run on August 1 every other year please?

 

Thanks

Priya

0 0

Replies

replied on July 2, 2019

The best I could come up with is a schedule that Starts on August 1, repeats daily, configure, every 730 days (2 years, notwithstanding leap years).

0 0
replied on July 2, 2019

Easy method:

Schedule the workflow to run everyday and have a condition in you worklow to check if today is the other August 1. You can use the token calculator to check if the year is an odd or even number with this formula:

ISODD(YEAR(%(Date)))

 

Script method:

Set an initial date in your starting rule and have a an SDK Script activity in your workflow update the date in your starting rule.

Sample Script:

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports Laserfiche.RepositoryAccess
Imports Laserfiche.Workflow.Objects 'Dont forget to add in Reference in the project explorer

Namespace WorkflowActivity.Scripting.SDKScript
    '''<summary>
    '''Provides one or more methods that can be run when the workflow scripting activity is performed.
    '''</summary>
    Public Class Script1
        Inherits RAScriptClass104
        '''<summary>
        '''This method is run when the activity is performed.
        '''</summary>
        Protected Overrides Sub Execute()
           'Create connection to workflow server
           Dim conn as Laserfiche.Workflow.WorkflowConnection = Laserfiche.Workflow.WorkflowConnection.CreateConnection("localhost","MyWF")
           'Retreive starting rule
           Dim startRule as Laserfiche.Workflow.Objects.ScheduledStartingRule = conn.Database.GetStartingRule("MyRuleName")
           'Get XML for rule
           Dim xmlRule as String = startRule.ScheduleXml
           'Get current year
           Dim currentYear As Integer = System.DateTime.Now.Year
           'Set next run in 2 year
           Dim nextYearSchedule = currentYear+2
           'Update XML
           xmlRule = xmlRule.Replace(currentYear.ToString,nextYearSchedule.ToString)
           'Update rule
           startRule.ScheduleXml=xmlRule
           startRule.Update
        End Sub
    End Class
End Namespace

 

Screnn1.png
Screen2.png
Screnn1.png (22.76 KB)
Screen2.png (62.8 KB)
0 0
replied on July 2, 2019

Thanks.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.