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

Quick Refresh External Objects with VBScript

Former Member
Former Member
Hi all,

I want to setup VBScript to a scheduler that performs a quick refresh on external objects at given intervals.

Does anyone have some examples or guidance on how to do this?

Best Regards,
Conny
  • Former Member
    Former Member
    Thank you for your reply Joonas.

    I managed to get the script done with searching the forums here and looking into the API documentation.

    The registry settings update requires users to view or edit the objects in order to sync, so we needed a VBScript.
    Place the .vbs in a folder on your server and have the client connection setup. The name of the vault should be the same as in the script.

    Here is the code for doing a quick refresh:

    ' Initialize the MFilesClientApplication object.
    Dim oClientApp: Set oClientApp = CreateObject("MFilesAPI.MFilesClientApplication")
    ' Log into a vault through a document vault connection "Your Vault".
    Dim oVault: Set oVault = oClientApp.BindToVault("Your Vault", 0, true, false)

    '0 = MFExternalDBRefreshTypeNone No refresh is performed.
    '1 = MFExternalDBRefreshTypeQuick The quick refresh searches for new items and imports them to M-Files.
    '2 = MFExternalDBRefreshTypeFull The full refresh updates all the changes. This operation can take several minutes.

    oVault.ObjectTypeOperations.RefreshExternalObjectType 102, 1 'where "102" is the object ID that you want refreshed and "1" is quick refresh.


    Best Regards,
    Conny
  • Both quick and full refresh for external objects run automatically in the background without user interaction, the default is that quick refresh runs every 15 minutes and the full refresh every 24 hours (see the linked document for details). There is also an option to manually refresh in both M-Files Admin and M-Files Desktop. Is there some reason why this standard behavior does not suit your use case?
  • Former Member
    Former Member
    Hi Joonas,

    If that would have been the case we would not have needed the script.

    This is according to the https://kb.cloudvault.m-files.com/Default.aspx?#3ECA226F-7B54-428B-B539-DE443E6134EC/object/3AEC36EE-946C-4B0C-9DE2-8BF82DED3078/latest
    4.1 Quick Refresh Interval
    The quick refresh operation is started automatically if the value list is requested by a client (for instance, the metadata card
    containing a property that uses an external value list or object type is viewed) and if the latest refresh was executed more
    than 15 minutes ago.


    When we are creating new objects, the automatic quick refresh is not activated.

    For example, a new object is created in the external list. The value list can thus not be requested. The user does not view any old objects, and the quick refresh is not triggered. The user does not want to manually refresh, so we do it on the server side. We had one user who had to wait 1.5 hours for the quick refresh, and that is why we need it.

    Best Regards,
    Conny
  • So in your case the external source has some very fresh data (added during the last 15 minutes) that is not yet available in M-Files when the user is creating new objects? Then I can understand needing a script solution to trigger the refresh. If possible, I would have the external system trigger the update after the new data has been added so that it is available in M-Files as soon as possible.

    If this is not the case and the quick refresh doesn't run automatically every 15 minutes, I suggest you contact your M-Files reseller to review the external connections, the refresh logic and possible issues with it.
  • Former Member
    Former Member
    Yes, that is true, the users need to link documents to the object, as it is used as a starting point.
    They cannot start using M-Files properly before the object is created.

    Thanks for the info about the external trigger, we will look into that.
    As for now, the quick refresh script solves the problem.

    Our M-Files reseller pointed us to the Default Refresh Logic and Configuration Options for External Value Lists and Object Types document.

    Best Regards,
    Conny