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

VAF C# copy Object AND set workflow state

Hi community, 

I'm working through the copyObject example https://developer.m-files.com/Samples-And-Libraries/Samples/Processes/Copying-Objects/ 

This works fine. Now I was wondering if and how it is possible to set the cloned object to a certain workflow (and workflow-state).

var ClonedObjectId = env.Vault.ObjectOperations.CreateNewObjectExQuick(
                env.ObjVer.Type,
                newObjectPropertyValues,
                newObjectSourceFiles,
                isSingleFileDocument,
                CheckIn: true,
                AccessControlList: accessControlList);

Since this "is not an object itself" but only returns the ID of the new created object.... My approach would be to pick up / search for the object with the ClonedObjectID and set the workflow / state afterwards.

However I figure I'd then would already create version 2 by changing the workflow (and workflow state).

Is there an approach to set the workflow / state right away?

Kind of looking for something like 

ClonedObject.SetWorkflowState(WF, WFS);

Thank you 

Best regards

Alex

Parents
  • The workflow and state properties are just property values on the object.  If you ensure that your "newObjectPropertyValues" collection includes valid values for these properties then the copied object would end up in the correct workflow/state.

    If you're using the VAF Extensions then there is an ObjVerEx.CreateCopy extension method which you may find makes this much easier.  It takes a set of instructions that you could use to overwrite the workflow and state properties with the values you need.

  • Hi Craig, thanks

    How do I set „valid values for these properties“?

    newObjectPropertyValues.SetProperty(...);

    Let‘s say I have a workflow state with ID 567? Or by MFIdentifier MyDesiredWorkflowState 

    Thanks &

    Best regards

    Alex

Reply Children