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-recalculate property for all objects in a vault

Hi,
Apologies if this is obvious somewhere, but I've looked, honest! Simple question: How can I automatically recalculate an automatically calculated property for all objects in the vault? I've already locked myself out of a couple of sandbox vaults trying to get this to work.

A bit more detail: The properties involved use a vbscript with an SQL query in it to get component data from an external database. One update a day is fine. But how?

Seems like this might be a bit buggy:
https://community.m-files.com/index.php?topic=11850.msg32810#msg32810
https://community.m-files.com/index.php?topic=6072.msg32806#msg32806

Is there a better way?

Thanks

Matt
  • Hi Moom

    In M-Files Admin, you can right-click the property and select Recalculate. This will ask you if you want to recalculate for all values, or only empty values.

    Kicking the recalculate off by script is currently not working correctly, according to the API documentation.
  • Hi ppickering,
    Thanks for the response. Not really what I wanted to hear - I don't really want to be opening M-Files Admin every day just to recalculate these values (hopefully there won't be any other need to open it!). I'm an engineer, I want to be out there hitting things with screwdrivers, etc.

    Okay. How about if I change tack? If I created a value list with all the data from the external database, and then changed the auto script for the property value to point to the value list, would that automatically update? I know the value lists update daily (at least), but would this rattle through to the property values? It seems like it might, but I don't know enough about how the property values pick up data from the value lists. If this approach works, it seems like it might be slightly clearer for future sysadmins, too.

    Easiest thing is to try it I guess. Anyone know off the top of their head how to write a vbscript to pick values from a list?
  • Hi

    You're right, you shouldn't be opening up Admin to run the recalculate every day. I suggested this thinking you were looking for it just as a one off.

    If the data on the object changes, whether through an update in M-Files or an update to the external data when it comes from another source, any automatic properties on the object will get updated to reflect what they should be at that point in time. So if the value on the drop-down property changed, then yes, an automatic property on the object would be updated if necessary. If the list of possible values changed on the value list, this may not impact any objects, because the data associated with the objects isn't changing.

    The easiest way to automate a recalculate might be to implement a workflow. It's a crude idea, and you cannot implement automatic state transitions in a loop, regardless of pre or post conditions, or transition triggers, but you could look at having a workflow with two stages.
    • You have stage 1 as an initial state that all objects will sit at.

    • Stage 2 runs a VBScript that sets the workflow state back to stage 1.

    • There is an automatic state transition pointing from stage 1 to stage 2, that triggers the transition if the modified date is not equal to the current date



    It's not an ideal solution; if it was me being asked to implement this, I wouldn't want to put our servers through such work every night, and the person requesting the feature would have to really justify why every object has to go through this process to make sure automatic values are recalculated.

    Or maybe I've got the complete wrong end of the stick? At this point, I don't know why you're asking about recalculating the property for everything in the vault, and maybe it's not actually necessary?
  • Sorry, I should have put in a bit more context.

    We're using M-Files to manage our mechanical CAD files (3D models and drawings, basically, with a few other hangers-on). I'm trying to set things up as a "one stop shop" for our designers, to save us from having to rummage through the ERP system (which like all ERP systems is extremely user unfriendly), so I want to include on the metadata sheet things like how many of a component we have in stock, how quickly we burn through stock, how much it is, where to find it in Stores, etc. So I have SQL links into the ERP system to extract this data and present it on the metadata card. Of course we don't burn through stock that fast, hence a daily update is fine.

    Most of the data items in the vault are CAD 3D models or drawings - it's the models that have all the metadata attached, so about 50% of the items in the vault. There's not that many of them (yet), so a workflow is potentially feasible, but it does seem... ungainly. I guess there are probably three properties that I really want to update regularly (stock size, cost, and usage rate), so that eases the load a bit further, doesn't it?

    More and more, though, I'm thinking what I should do is set up a series of value lists, linked by part number, and then re-write the property scripts so that they use the part number as a look-up to return the cost/stock size/UR.
  • That sounds very much like the data you'll be pulling through, from the ERP system, will be changing quite frequently, so it might be you can get away without having to implement any solution. The connection to the external source will update the information held in M-Files periodically (I've been trying to find out how often, and when, but can't find anything to help on this), so if anything changes on an object as a result of this, any automatic properties on the object will also update.

    Does that help, or does it sound like you still might need something that makes sure items get updated at least on a daily basis?