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

Batch to recalculate a property everyday

Former Member
Former Member

Hi every one,

i'm totaly new with M-Files and I'd like to know if there is a way to automaticaly recalculate the property of an object every day.

Thanks

  • You could place the object in a workflow that automatically cycles on a daily basis.
    M-Files workflows will not allow a loop directly in automatic transitions, but you can insert a script that will change the workflow state back to a previous state.
    State 1 -> automatic transition after one day -> State 2, action script that changes the workflow state back to State 1.
    The script below assumes you have Aliases on your workflow states. If not, you can look up the ID manually and insert that in the script in stead.

    Option Explicit
    dim iWFState : iWFState = vault.WorkflowOperations.GetWorkflowStateIDByAlias("")
    Dim oPropVal: Set oPropVal = CreateObject("MFilesAPI.PropertyValue")
    oPropVal.PropertyDef = 39 ' Workflow states build-in property
    oPropVal.TypedValue.SetValue MFDatatypeLookup, iWFState
    Vault.ObjectPropertyOperations.SetProperty ObjVer, oPropVal
  • Is it possible to modify the script so it goes back to the previous state without hardcoding it?

  • That should be possible. You would have to get the version number of the previous version, get the propertyvalues from that version and then get the value of the workflow state. I do not have a script on hand for that nor do I have the time to create one at the moment.

  • I can't help with the scripting side of things but something like this is the right idea.

    You can setup scripts via some trigger, like a workflow or event, but there isn't a way to setup a scheduled task that would run a script or similar in a vault. To do something scheduled without a workaround like this would be to create an external application via the API.

    https://developer.m-files.com/

  • You can develop recurring background tasks with the Vault Application Framework: https://developer.m-files.com/Frameworks/Vault-Application-Framework/Multi-Server-Mode/Recurring-Tasks/

    Recurring tasks would be my recommendation technically but I know there's a learning curve when starting VAF development so likely this would need to be implemented by someone with VAF experience.

  • Very good library - I'm just trying this out.

    But if things like that have also a low code alternative it would be even better. I've just tried out Compliance Kit Managed Properties and I am willing to replace a lot of VAF event handlers by this possibility.

    Workflow state action can set values - e.g. set "approval done" to yes - but "approved by" and "approved at" (date) cannot be set by that. - Why not?

    But I did a work around using managed properties to set the "by" and "at" values to current user and current date when it is empty and "done" has been set to "yes". Works fine Slight smile

    {
    "Property": "EW.PD.GenehmigungDurch",
    "CalculationRules": [
    {
    "Name": "Default",
    "Value": {
    "Mode": "Dynamic",
    "DynamicValue": "%PROPERTY_23%"
    },
    "Filters": [
    {
    "conditionType": "equal",
    "expression": {
    "type": "propertyValue",
    "propertyDef": "EW.PD.GenehmigungDurch",
    "indirectionLevels": []
    },
    "typedValue": {
    "dataType": "lookup",
    "value": {
    "isNull": true
    }
    }
    },
    {
    "conditionType": "isNotMissing",
    "expression": {
    "type": "propertyValue",
    "propertyDef": "EW.PD.GenehmigungDurch",
    "indirectionLevels": []
    },
    "typedValue": {
    "dataType": "lookup",
    "value": {
    "isNull": true
    }
    }
    },
    {
    "conditionType": "equal",
    "expression": {
    "type": "propertyValue",
    "propertyDef": "EW.PD.GenehmigungErfolgt",
    "indirectionLevels": []
    },
    "typedValue": {
    "dataType": "boolean",
    "value": {
    "boolean": true
    }
    }
    }
    ]
    }
    ]
    }

  • In addition to that: Is there any project to collect low code automatism like managed properties in compliance kit as a kind of community add-in?