1
votes

I am trying to follow the tutorial: https://msdn.microsoft.com/en-us/library/gg509012.aspx

However, when I get to the line:

protected override void Execute(CodeActivityContext executionContext)
{
    IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

    //Create an Organization Service
    IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
    IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);

    //Retrieve the contact id
    Guid contactId = this.Contact.Get(executionContext).Id;
}

It is giving an error in C#.

C# 'Program' does not contain a definition for 'Contact' and no extension method 'Contact' accepting a first argument of type 'Program' could be found are you missing a using directive or an assembly reference?

What is this.Contact?

1

1 Answers

3
votes

Contact is an in argument for the custom activity workflow

//Define the properties
[RequiredArgument]
[Input("Update Next Birthdate for")]
[ReferenceTarget("contact")]

public InArgument<EntityReference> Contact { get; set; }

protected override void Execute(CodeActivityContext executionContext)
{
    IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

    //Create an Organization Service
    IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
    IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);

    //Retrieve the contact id
    Guid contactId = this.Contact.Get(executionContext).Id;
}

When you invoke the custom, from a workflow or an action, you have to send the required input arguments, like Contact.