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

Set Automatic Value For Date?

Former Member
Former Member
Hi Everyone,

My Question is very simple ;

I have a propery field called = "Document Date" is it possible to set its value to something like "DateAndTime.Now" by a VBScript?.
  • Former Member
    Former Member
    Search for "MFDatatypeDate" in the APi help.

    This should get you started:

    [...]
    ' Create new property value.
    Dim oPropertyValue As MFilesAPI.PropertyValue = New MFilesAPI.PropertyValue
    oPropertyValue.PropertyDef = 1096 ' In this case, represents the "Effective through" property
    oPropertyValue.TypedValue.SetValue(MFilesAPI.MFDataType.MFDatatypeDate, DateSerial(2015, 1, 1))

    ' Modify the object. The object needs to be in checked out state.
    oVault.ObjectPropertyOperations.SetProperty(oObjectVersionAndProperties.ObjVer, oPropertyValue)

    Of course you will need to adjust it a bit. I believe the vb function to get the current time is "now()" or something similar.
  • Former Member
    Former Member
    This is working fine in state's vbscript

    '--------------------------------
    Function MsgBox(msg)
    Err.Raise MFScriptCancel, msg
    End Function
    '--------------------------------

    Const IPropDate = 1069

    Dim oPropertyValue : Set oPropertyValue = CreateObject("MFilesAPI.PropertyValue")
    oPropertyValue.PropertyDef = IPropDate
    oPropertyValue.TypedValue.SetValue MFDatatypeDate, DateSerial(Year(Now), Month(Now), Day(Now))

    Vault.ObjectPropertyOperations.SetProperty ObjVer, oPropertyValue


    If you want to have a calculated value you may use this :


    '--------------------------------
    Function MsgBox(msg)
    Err.Raise MFScriptCancel, msg
    End Function
    '--------------------------------

    Output = DateSerial(Year(Now), Month(Now), Day(Now))
  • I just attempted this code, with an alteration to access an existing property by Alias.

    It appears to work well, thanks for the code.
  • Former Member
    Former Member
    Can setting the current date be done without code? We are cloud based and cannot apply vbscript to workflows.
  • You should be able to do that in Metadata Card Configuration. You can set a dynamic value.
  • Former Member
    Former Member
    Yes I'm aware that can be done at the metadata card configuration. I would like to clarify, I need to setup the current day on the metadata card once an assignment is approved and then a second date field to be set a year from the current date. This is to setup a reminder when documents are due. Can this be done via workflows?
  • You might be able to use the free of charge Compliance Kit, Configuration Accelerators add-on, in particular the Managed Properties module, Auto Calculated Property feature.
    You can configure it to set a dynamic value in your property depending on other metadata, current date etc.
    Not 100% certain that you can actually add a year to current date, but I don't see why it should not be possible.
    Alternatively you could create a separate assignment in your workflow to work as a reminder with deadline one year ahead. The downside of that is that this assignment will show up in lists during the long waiting period.
    I prefer to create a separate Task-object with a workflow that keeps it waiting silently until a specified notify date is reached. At that time a new assignment is created by the workflow. But this approach also requires some scripting if you want things to be automated...!

  • Can setting the current date be done without code? We are cloud based and cannot apply vbscript to workflows.


    I would certainly take a look at the Configuration Accelerators, as bright-ideas.dk suggested. However, for clarity, it is possible to add code to workflow states in cloud environments. If you want to do this then you need to liaise with your M-Files Partner or Account Manager, as code needs to be manually vetted by our cloud ops teams before it's able to be applied in cloud environments. There may be a charge for this vetting process.

    Regards,

    Craig.