This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Workflow Automatic State Transition by calculated date

Former Member
Former Member
Hi

I was wondering if it is possible to define a automatic state change on a workflow based on a date, that has been calculated using an object's date property.

Regards

Yaney
Parents
  • Have used the script below to delay state transition i various situations. You can easily adapt it to trigger after e.g. 6 hours.
    Have used it in a combination of 2 workflow states where this script after a defined pause triggers a transition to the next state where another script in Workflow Actions sends the object back to the original state. Effectively the workflow repeats itself with the delay defined in this script plus some delay that comes from the interval set on the M-Files for how often the server checks whether transitions meet the criteria set in their configurations.
    'Make workflow pause x minutes before moving on
    'Will only work on new objects because it compares Created time to present time, consider using LastModified (21) if relevant.
    'Delay will be minimum the specified x minutes. Can be up to 60 + x minutes depending on when M-Files server checks the conditions.
    'Script to be placed in Transition Trigger
    '2019.07.04 Karl Lausten
    Option Explicit
    Dim dCreated : dCreated = PropertyValues.SearchForProperty(20).TypedValue.GetValueAsTimeStamp().UtcToLocalTime().GetValue()
    'Desired delay in minutes:
    Dim iDelay : iDelay = 5
    Dim dGoAhead : dGoAhead = DateAdd("n",iDelay,dCreated)
    'test time settings to verify the setup.
    'err.raise mfscriptcancel, "dCreated (UTC converted to local time):" & dCreated & ", dGoAhead: " & dGoAhead & ", now (local time):" & now
    if now > dGoAhead then
    AllowStateTransition = True
    end if
Reply
  • Have used the script below to delay state transition i various situations. You can easily adapt it to trigger after e.g. 6 hours.
    Have used it in a combination of 2 workflow states where this script after a defined pause triggers a transition to the next state where another script in Workflow Actions sends the object back to the original state. Effectively the workflow repeats itself with the delay defined in this script plus some delay that comes from the interval set on the M-Files for how often the server checks whether transitions meet the criteria set in their configurations.
    'Make workflow pause x minutes before moving on
    'Will only work on new objects because it compares Created time to present time, consider using LastModified (21) if relevant.
    'Delay will be minimum the specified x minutes. Can be up to 60 + x minutes depending on when M-Files server checks the conditions.
    'Script to be placed in Transition Trigger
    '2019.07.04 Karl Lausten
    Option Explicit
    Dim dCreated : dCreated = PropertyValues.SearchForProperty(20).TypedValue.GetValueAsTimeStamp().UtcToLocalTime().GetValue()
    'Desired delay in minutes:
    Dim iDelay : iDelay = 5
    Dim dGoAhead : dGoAhead = DateAdd("n",iDelay,dCreated)
    'test time settings to verify the setup.
    'err.raise mfscriptcancel, "dCreated (UTC converted to local time):" & dCreated & ", dGoAhead: " & dGoAhead & ", now (local time):" & now
    if now > dGoAhead then
    AllowStateTransition = True
    end if
Children
No Data