谁能提出我在这里做错了什么?
我使用此示例Create a custom workflow activity创建了一个自定义工作流活动.但这并未在插件注册工具中显示为插件/活动类型.见下图:
我的活动示例代码如下:
代码更新
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); } } }
平台
Dynamics CRM 2013 On Premises v 6.1.2.112(已安装SP1 UR2)
Dynamics CRM 2015在线
.NET Framework版本
4
解决方法
您的控股课程需要公开吗?
class TestWfActivity
应该
public class TestWfActivity
或者,Activity类应直接驻留在您的namepspace中,而不是使用TestWFActivity类.
试试 –
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); } } } }
要么
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); } } }