Search code examples
c#dynamics-crm

MS CRM Custom Workflow Activity output with generic type


I would like to write a Custom Workflow Activity which will return a value from a parent object from the parent object of an entity. For example I am on Entity A here I have a lookup field to Entity B and here I have a lookup field to Entity c. On Entity c there is a given field which value I want to return.

Is it possible to make a generic output type, so that the Custom Workflow Activity can either return a lookup or any other supported datatype?

Thanks!


Solution

  • It is not possible to add an OutArgument<T> of any type other than the supported types (as listed on MSDN).

    I see two workarounds:

    1. Add an OutArgument<string> and store a serialized EntityReference object in it. Downside of this approach is that your parameter can only be consumed by another custom workflow activity.
    2. Add an OutArgument<EntityReference> for every entity type your workflow activity needs to support. If you are lucky you only need a few.