I'm creating a document with object creator copy rule and let it convert to pdf via state action.. Problem is that the document isn't filled.. Is this normal behaviour?
It might help if you make sure the document is actually checked in before it is converted to PDF. If you a workflow with automatic transitions then the document will not be checked in before the last state in the line of automatic transitions. I have often placed a pause in flow with a script comparing the last modified time stamp to current time and setting a minimum difference to a few minutes. This will make the transition wait til next time the server checks, and your document is checked in. That should force filling of the properties. The downside is that you have to wait for up to an hour for the PDF version unless you reduce the interval on the server.
If I recall right by default the values are filled in the template only when the user opens the document in Office so in case the file is never opened by the user before the PDF conversion (ie. it only moves in the workflow) then see if this option would help: Enabling Metadata Field Updates for the Classic M-Files Web and M-Files Mobile (it says web and mobile but the filling is done on the server during check-in so should work with any client)
It's also possible to call the VaultObjectFileOperations.UpdateMetadataInFile method in the API explicitly in the workflow before the PDF conversion to have the values filled in.
I already have this option activated for Word and Excel Extensions, but no effect in this case.. Calling VaultObjectFileOperations.UpdateMetadataInFile method in a separate state before the pdf conversion state works if I send the object in this state manually.. But with my copy rule the result is a pdf with no properties filled in..
That is my point - if using automatic rules/transitions the document does not get checked in and the placeholders in the document do not get filled unless you add a pause in the process to force a check in. When you do it manually it works because the document gets checked in.
There is a script in this topic: community.m-files.com/.../10703
And If I give the document a boolean property "Convert PDF" and add an eventhandler which checks this property after document checkin and if it is true initiates the conversion? Then you could set this property at through different ways (metadata card, object creator, automatic properties, workflow states) and voila
© 2025 M-Files, All Rights Reserved.