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

Saving metadata without checking-out document

Hi. 

I would like to ask a question. When I change document metadata with a workflow state, they are not displayed in the document until it´s checked-out. Is there any way how to automate this thing with the script? I am not sure if I read well that this can be done only with VAF? 

Thank you very much for your help. 

  • Hi Lola,

    Not quite sure if I understand correctly but here some thoughts.

    Generally, in workflow pre/post conditions and state actions, you should be able to set property values without checking out objects as in that moment of time you have ObjVer and opened transaction. You can use VAF (C# .NET) or you can script it in VB script (would generally recommend VAF, better for maintenance).

    If you have simple value setups (e.g. static values, or some simple calculations), you can easily set it up in workflow pre/post conditions without coding (e.g. setting fixed state property, current date time etc.)

    Displaying of metadata is not really connected with setting values and you can controll it through metadata card rules.

    These are ways to setup workflow actions in VAF: https://developer.m-files.com/Frameworks/Vault-Application-Framework/Attributes/Workflows/.

    Dejan

  • Hi Dejan. 

    Thank you very much for your answer. I know about coding and using VAF. I just wanted to know if it´s possible to code my issue in VB script as I am not familiar with C#. The problem is that I have a Word document, I fill in some metadata in M-Files like by whom it was approved and on what date but then I would like to display these data straight in the Word file without pushing user to check-out document. When you open it as read-only, you can see that the data are not in there. And this should be done with the code in Workflow when it reaches relevant state. Don´t know if I am clear enough.  

  • I thought that it could be something like this. To open the document for editing where file is automatically checked-out, but it´s not doing anything.

    If ObjVer.Type = MFBuiltInObjectTypeDocument Then 


    Dim PropertyValues: Set PropertyValues = Vault.ObjectPropertyOperations.GetProperties(ObjVer)

    Dim oFiles: Set oFiles = Vault.ObjectFileOperations.GetFiles(ObjVer)

    If oFiles.Count > 0 Then
    Dim oFile: Set oFile = oFiles.Item(1)

    oVault.ObjectFileOperations.OpenFileInDefaultApplication Application.Hwnd, ObjVer, oFile.Version, MFFileOpenMethodEdit

    End If 

    End If

  • Hi Lola,

    I understand what you mean. We have similar usage of templates with user names, approval dates etc. We have experienced the same behavior. We usually set approval dates in state actions or pre-conditions but they are often not shown until the user check out document. 

    What you can try is to convert document into PDF in preview and see if it helps. In our case, it sometimes work and sometimes does not show values for those placeholders. I wrote couple of times about it in forum. Still this will not help you if your user has only read only rights and try to open the document. In most cases, it would not have calculated values. I personally also do not understand why this is not working correctly as the calculation happens on the server and placeholders should have been applied.

    I would be also very interested if someone finds good solution for this one.

    Dejan

  • There is a configuration option to enable template metadata updates during check-in, this is disabled by default as it may have a negative performance impact in some environments. Instructions for enabling in the user guide: https://www.m-files.com/user-guide/latest/eng/enabling_metadata_field_updates_in_web_and_mobile.html Not sure if this helps in your case but you could try it and see if it would save you the trouble of scripting.

    If you end up needing a scripted solution, you can call the UpdateMetadataInFile method in the API to update the embedded metadata.

  • Hi Joonas and Lola, 

    I have wrote about this problem one year ago: https://community.m-files.com/forums-1552881334/f/m-files-server-configuration/4623/ms-word-templates-behavior. In that moment of time, the feature you recommend behaved very strange and did not really work well.

    I have re-tested again and unfortunately for us it still does not work as expected. We have now behavior that on word documents placeholders are getting applied immediately (actually expected) after save and without checkout. This is great but when final document is created as PDF using workflow state option "Convert to PDF / Store each PDF as a separate file", it created PDF without last approval date of user who moved document to last workflow state. We calculate date and time in pre-condition of the state so it is definitely provided when on workflow state M-Files tries to create PDF. Word document contains all approval dates but now our final PDF documents (actually more important for end users) do not have the date of last approver. So it seems we have reverted our problem, now PDF is not containing all dates but Word has it; before it was other way around.

    It is quite deterministic and problem goes away if I set a feature on "No" and remove "docx" from extensions (if I keep "docx" in extensions but set feature on "No" problem still occurs which is really strange).

    It would be really good if someone from M-Files can reproduce it and create a bug. This is such a crucial feature and it would be great it is finally fixed and works correctly. 

    I revert it back as for us are final PDF documents more important as working copies.

    Thanks.

    Dejan

  • Hi All, 

    thank you very much for all your help. 

    I guess that I could live at least with the possbility to have all data in Word document before converting it to pdf, but when I add the extension in advanced vault settings it doesn´t work. I am just wondering when you´re mentioning that you set the feature on "No". Where can I do that? Haven´t found anything like that in manual Jonaas mentioned above. Just want to be sure if I am not missing anything here? 

    Thanks. 

  • Hi Lola, 

    This is how I configured it:

    Let us know how it works for you. Perhaps if you have at the end of your workflow PDF creation.

    Thanks 

    Dejan

  • Thank you Dejan. I don´t have that possibility in M-Files. Maybe it´s because of an older version? Don´t know. I will consult it with our provider.

    Again, thank you so much for your help! 

  • It works! Thank you so much! Slight smile Just didn't know, that I have to click on File Operations not the Extension Filter for Embedded Metadata Update on Check-in option to display the feature. Great!