1

I have a requirement to read a value from a field in the current component in an external workflow activity using SDL Web 8.

I load the ComponentData using the following line of code:

ComponentData workflowItem = (ComponentData)CoreServiceClient.Read(ActivityInstance.WorkItems[0].Subject.IdRef, new ReadOptions());

//Note: I know the above will not work well if the item is in a bundle, and will fail if the workflow is a Page item

This works fine when creating a new component. When the item reaches this activity, the version is 0, and the revision is 1, and I get the current values of the component. So far so good.

The second time the item goes through workflow, the Component is retrieved, but it contains the old values, and not the field values which have been modified in the current workflow process.

How can I reliably access the current component that is in workflow.

1 Answer 1

5

If you use Subject.IdRef without specific ReadOptions you will get the last major version, which will have the old values.

In order to change this behaviour, you will need to pass additional ReadOptions (example below)

ComponentData currentWorkflowItem = (ComponentData)CoreServiceClient.Read("", 
                                new ReadOptions()
                                    {
                                       UseDynamicVersion = DynamicVersionResolvingConditions.CheckedOutByUser 
                                    });

There are several options for DynamicVersionResolvingConditions which are

  • Never - It should never be resolved unless explicitly requested in Id.
  • CheckedOutByUser - Resolve to dynamic version if the item is checked-out by the user.
  • ReservedAndRevisedByUser - Resolve to dynamic version if the item is reserved and the user is the last revisor.
  • AssignedToUser - Resolve to dynamic version if the item is in the user's assignment list.
  • ReadableByUser - Resolve to dynamic version either if any of the other condition is true or the user is an Administrator.
3

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.