Hi,
I have this kind of setup:
- M-Files is importing XML-files (could be an update to existing objects or just new objects) from a folder. The XML-file may contain 1 to N sections from which objects need to be created.
- A legacy VBScript gets triggered from the BeforeCreateNewObjectFinalize-event and it checks if it was caused by an XML-file from the correct source and only handles those.
- It then processes the XML-file and first deletes all old objects for that particular batch and then creates new objects from the XML data. So the flow is always to delete all + create new objects.
There is also a VAF in this datastore and I need to execute an operation in the VAF that will update couple of properties on those newly created objects that are left empty in the VBScript when the objects are created. The VAF should be executed ONLY after all of those objects have been created because it needs to do use all those objects to calculate something and after that run updating on all objects individually. Let's say that this property could be for example % of weight that one object has of the total weight from all objects. So for that I need to update each object by searching and summing all objects with the same parent ID and then calculating the % individually for each object. I do need some other info from some other objects as well at this point so it's not only the data contained inside the objects.
In the VAF, I seem to have hard time catching the moment when all those objects have been created as in the VAF code I don't know how many there will eventually be and which one is the last one after which the mass-update could be done.
In the VBScript I obviously do know when all objects from particular XML-file have been created but I somehow need to pass that event to the VAF. Of course I could also do the group updating in the VBScript, but these are legacy scripts done by someone else before me and I want to do minimal updates on them and rather do all proper logic in VAF. I could rewrite the whole XML-import logic in VAF also, but at this moment the VBScript is a bit too critical and tough to decipher that it's not a realistic option for now, maybe later.
Now, I'm thinking that the only way to do this properly is to create an extension method on the VAF and then call that from VBScript and pass the common parent ID (all objects have a common ID and then an incrementing serial number) and that would trigger my VAF processing and there I could just search for all those objects when I know that common parent ID and their type. Another way which I think is not possible, would be to have some sort of custom event, like "All Objects Created" that could be handled in VAF and published in VBScript but I guess that doesn't differ much from an extension method call.
Is the extension method call the best way to do such a thing or is there any other recommended way?