Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Workflow Activity not showing in Plugin Registration

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

like image 368
Khadim Ali Avatar asked Apr 16 '15 09:04

Khadim Ali


People also ask

How do I register a custom workflow using plugin registration tool?

Open the Plugin Registration Tool (PRT), and select Register->Register New Assembly: Once registered, you will see the assembly in the list: Now let's go to Dynamics 365 / PowerApps and create a new Workflow called Set State to New York on the Account: Click Add Step.

How do I register a workflow activity?

Click on Register >> Register New Assembly. The "Register New Assembly" popup will appear; select your project DLL from bin/debug folder of the project. After selecting DLL, make sure that Select All is selected in Step 2. Leave the rest of the options as they are and click Register Selected Plugins.

What is difference between custom workflow and plugin?

A Custom Workflow Activity Plugin is very similar to a Plugin exempt that it is executed from within a CRM Workflow, Whereas Plugins Are executed on Events that Occur on the Entity, So workflow Activities give you more control when the plugin will be executed as well as allowing you to configure some logic through the ...


2 Answers

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);

            }
        }
}
like image 50
DotNetHitMan Avatar answered Nov 15 '22 08:11

DotNetHitMan


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.

like image 26
SebastianC Avatar answered Nov 15 '22 08:11

SebastianC