Document version as metadata

Hi all, is there any way to implement version numbering using metadata added through a workflow which starts at “0.0” upon the upload of a file and is incremented whenever the document goes back to a Draft state?

Thanks

Hi all, I solved it by creating a metadata for the document, assigning 0 as creation and on a workflow , when it enters a stage simply do this

{{ workflow_instance.document.metadata_value_of.EPCDoc_RevNum|add:1 }}

1 Like

Hi again, just another update regarding what I’ve implemented:

What I wanted: metadata named Revision Number that could be seen by all Users but not edited by them, that would start at 0 upon the upload of a document and increment 1 unit whenever it returns to its Draft state during a workflow.

Implementation:
Action upon entry on Draft state - Add RevNum Metadata with the following condition:

{% if workflow_instance.document.metadata_value_of.EPCDoc_RevNum == None %}
True
{% endif %}

Action upon entry on Draft state - Edit RevNum Metadata with the following condition:

{% if workflow_instance.document.metadata_value_of.EPCDoc_RevNum == None %}
0
{% else%}
{{ workflow_instance.document.metadata_value_of.EPCDoc_RevNum|add:1 }}
{% endif %}

It works as intended, my only question is that these two actions, adding and editing the metadata, occur on the same step (upon entry to Draft state) and, thankfully, the steps occur in the correct order, which I believe is intentional, but cannot explain why.

What I mean is, can an error ever occur where the edit metadata action occurs first and, since it wont have the metadata added yet, fails?
It’s OK since it’s currently working, I’m just curious to find out how it’s processed