Notification setup - 1st day of each month

Hi! Does anybody know how to setup a notification to be sent to a user on the 1st day of each month?

As i want to customise the notification I setup a workflow with 1 state only for this.

Basically on the 1st day of each month the workflow is triggered and sends a link to a view to a user.

Any ideas?

Many Thanks,

Nuno

Parents
  • HI Nuno,

    I found a way to do this. I will try to explain it here as well as I can. If anything is unclear, please ask.

    I created a Date property definition named "First Day of Next Month" and gave it an automatic value using Calculated Value (VBScript) with the following code.

    Output = DateSerial(Year(Date), Month(Date) + 1, 1)

    This value will be updated whenever the object is modified.

    Then, I created a simple workflow, the automatic state transition happens when the DaysFrom "First Day of Next Month" = 0

    In the "Send Notification" state, you configure the notification you wish to send and then add the following code to Run Script on the Action Tab (make sure to use the correct Alias for your "Pending First Day of Month" state:-

    Option Explicit

    Dim PendingFirstDayOfMonthWFStateID : PendingFirstDayOfMonthWFStateID = Vault.WorkflowOperations.GetWorkflowStateIDByAlias("WFS.SendNotificationOnFirstOfMonth.PendingFirstDayOfMonth")
    Dim oPropVal: Set oPropVal = CreateObject("MFilesAPI.PropertyValue")

    oPropVal.PropertyDef = 39 ' Workflow states build-in property

    oPropVal.TypedValue.SetValue MFDatatypeLookup, PendingFirstDayOfMonthWFStateID

    Vault.ObjectPropertyOperations.SetProperty ObjVer, oPropVal

    What should happen is that you created your object and the "First Day of Next Month" gets set. When the first day of the month arrives, the automatic state transition happens. This will send your notification, recalculate the "First Day of Next Month" value and the Script will return the object to the "Pending First Day of Month" state.

    Please test this before using it in your production environment.

Reply
  • HI Nuno,

    I found a way to do this. I will try to explain it here as well as I can. If anything is unclear, please ask.

    I created a Date property definition named "First Day of Next Month" and gave it an automatic value using Calculated Value (VBScript) with the following code.

    Output = DateSerial(Year(Date), Month(Date) + 1, 1)

    This value will be updated whenever the object is modified.

    Then, I created a simple workflow, the automatic state transition happens when the DaysFrom "First Day of Next Month" = 0

    In the "Send Notification" state, you configure the notification you wish to send and then add the following code to Run Script on the Action Tab (make sure to use the correct Alias for your "Pending First Day of Month" state:-

    Option Explicit

    Dim PendingFirstDayOfMonthWFStateID : PendingFirstDayOfMonthWFStateID = Vault.WorkflowOperations.GetWorkflowStateIDByAlias("WFS.SendNotificationOnFirstOfMonth.PendingFirstDayOfMonth")
    Dim oPropVal: Set oPropVal = CreateObject("MFilesAPI.PropertyValue")

    oPropVal.PropertyDef = 39 ' Workflow states build-in property

    oPropVal.TypedValue.SetValue MFDatatypeLookup, PendingFirstDayOfMonthWFStateID

    Vault.ObjectPropertyOperations.SetProperty ObjVer, oPropVal

    What should happen is that you created your object and the "First Day of Next Month" gets set. When the first day of the month arrives, the automatic state transition happens. This will send your notification, recalculate the "First Day of Next Month" value and the Script will return the object to the "Pending First Day of Month" state.

    Please test this before using it in your production environment.

Children