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:
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
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.
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.
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 ...
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);
}
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With