Custom workflow how to get a runtime object

This is my first custom WF for CRM 2011, and it should have been a universal EF for any object, I would like to know how to get the executable from the context, or if this is not possible, any idea would be very nice.

I run WF as follows:

public class WFIntegracao: CodeActivity
    {

        protected override void Execute(CodeActivityContext context)
        {

            IWorkflowContext contexto = context.GetExtension<IWorkflowContext>();


        }
    }
+5
source share
2 answers

IWorkflowContext must contain the required information.

IWorkflowContext contexto = context.GetExtension<IWorkflowContext>();
String entityName = contexto.PrimaryEntityName;
Guid entityId = contexto.PrimaryEntityId;

MSDN IWorkflowContext

+4
source

I had not done a workflow for objects of an indefinite type before, however you could modify this code to do this; This is for link to contact:

[RequiredArgument]
[Input("Contact")]
[ReferenceTarget("contact")]
public InArgument<EntityReference> Contact { get; set; }

protected override void Execute(CodeActivityContext context)
{
    ContactReference = Contact.Get(context);
    if (ContactReference == null)
        throw new InvalidPluginExecutionException("Contact reference is null.");

    DoSomething();
}

, , . , ReferenceTarget, . , LogicalName .Get(), :

string entityType = ContactReference.LogicalName;
0

All Articles