7
votes

Could anybody suggest what I am doing wrong here?

I have created a Custom Workflow Activity using this sample Create a custom workflow activity. But this is not showing up as a plugin/activity type in Plugin Registration Tool. See image below:

enter image description here

My sample code for the activity below:

CODE UPDATED

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;

namespace TestCustomWorkflowActivity
{
    public class SampleCustomActivity : CodeActivity
    {
        protected override void Execute(CodeActivityContext executionContext)
        {
            //Create the tracing service
            ITracingService tracingService = executionContext.GetExtension<ITracingService>();

            //Create the context
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

        }
    }
}

Platform
Dynamics CRM 2013 On Premises v 6.1.2.112 (SP1 UR2 installed)
Dynamics CRM 2015 Online

.NET Framework version
4.0

2

2 Answers

8
votes

Is it a case that your holding class needs to be be public?

class TestWfActivity

Should be

public class TestWfActivity

Or that the Activity class should reside directly from your namepspace rather than insdie the TestWFActivity class.

Try either -

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;

namespace TestCustomWorkflowActivity
{
    public class TestWfActivity
    {
        public class SampleCustomActivity : CodeActivity 
        {
            protected override void Execute(CodeActivityContext executionContext)
            {
                //Create the tracing service
                ITracingService tracingService = executionContext.GetExtension<ITracingService>();

                //Create the context
                IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
                IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

            }
        }
    }
}

or

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;

namespace TestCustomWorkflowActivity
{

        public class SampleCustomActivity : CodeActivity 
        {
            protected override void Execute(CodeActivityContext executionContext)
            {
                //Create the tracing service
                ITracingService tracingService = executionContext.GetExtension<ITracingService>();

                //Create the context
                IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
                IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

            }
        }
}
7
votes

I had the exact same issue while working with CRM 2013 (both on-premise and online). I never managed to actually solve the issue, but easily worked around it by using the Registration Tool from 2015's SDK instead. For unknown reasons that one works better.