I have to set a document upload & approval workflow, where a condition should be placed in the beginning to check if the document already existing in the library. Based on the output of the conditional check, further steps will be carried out. How can I achieve this? Also how can I read the metadata/column values of an existing item? Can anyone help me on this?
Assuming you know the file name or some metadata value, create a site workflow and use the "Query list" action. Filter on the known value you are looking for and put the metadata (or some other associated value) of that item in a variable. Next add a "Set a condition" action and test to see if the variable "is empty". If it is empty, the file was not found. If it is not empty, the file was found and you can run actions down either side of the condition tree.
Firstly, SharePoint doesn't allow to upload duplicate documents in a document library. If you would like to check for the document existence with same title and extension then as Patrick suggested "Query list" actions would help with filter condition on metadata ( Title, type ..etc ).
The item/document on which the workflow is running is accessible in any workflow action, take an example of " set a condition" or any action, the option "if current item field value equals" is available to check for any field of the current item.
Hope this helps.