0

I have a document library which has some documents with metadata fields attached. Some of the metadata fields are edited by a workflow on create / edit. But we are finding when a file is Published from draft to pending, the workflow fires and makes the required change to a metadata tag, and this causes that file to go back into draft mode.

Is it possible to make a change in a workflow and not changing the approval status?

2 Answers 2

0

This can be done with two separate calls to the API, Michael.

First make a validateUpdateListItem changing (for example) the 'Editor' field. This can include other fields with it if you need to economise on your actions.

Then make your last call in the workflow another validateUpdateListItem and edit ONLY the '_ModerationStatus' field.

If you wish to maintain the Approval Status that the item had before you started on it you can store the value 0-3 (or 4, I forget) up front and use that. Or just set the value of the '_ModerationStatus' field to "0" for Approved.


What's different about the '_ModerationStatus' field? I honestly couldn't tell you, however whatever it is, it is clearly transparent in terms of changing it as usually any other field (but 'Editor', ironically) would change the 'Editor' field. This one does not.

-1

In order to make that behavior you need to update the document metadata without firing native event receivers on changes.

If you’re on-premise and your workflow is based on custom development, you can use the trick to disable event firing with SPListItem.SystemUpdate(false)

Otherwise you have another workaround available on on-premise or online by using CSOM or Rest API “SP.ListItem.validateUpdateListItem” Microsoft Documentation: https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj246412(v%3Doffice.15)

CSOM example: https://www.c-sharpcorner.com/blogs/update-a-sharepoint-listitem-without-increasing-its-item-file-version-using-sharepoint-client-side-modelcsom

Rest API explanation: https://robertschouten.com/2018/04/30/update-file-metadata-with-rest-api-using-validateupdatelistitem-method/

Hope it will help you. Have a good day. Regards.

1
  • 1
    Thanks for the reply. but I ran a test using validateUpdateListItem and unfortunately even with the bNewDocumentUpdate flag (i tried both on and off) but it still moved the file into draft.. If I was on Prem it would be easy using SystemUpdate, but it doesnt look like SPO offers anything for this problem
    – Michael
    May 27, 2019 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.