我在VS 2017中为自定义wf程序集进行了构建。
以下是我的代码。没有红色的花花公子,并且注册没有错误:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using Microsoft.Xrm.Sdk.Query;
namespace CustomerAsset
{
public partial class CustomerAsset : CodeActivity
{
//public InArgument<EntityReference> CustomerAsset { get; set; }
protected override void Execute(CodeActivityContext executionContext)
{
//Create the tracing service
ITracingService tracer= executionContext.GetExtension<ITracingService>();
tracer.Trace("Begin Plugin Execution");
//Create the context
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
try
{
//DO WORK HERE
Entity entity = (Entity)context.InputParameters["Target"];
var targetCustAssOpHrsId = entity.Id;
tracer.Trace(entity.LogicalName);
tracer.Trace(targetCustAssOpHrsId.ToString());
QueryExpression qe = new QueryExpression();
}
catch(Exception ex)
{
throw new InvalidPluginExecutionException("error in CustomerAsset custom workflow assembly");
//throw new InvalidPluginExecutionException(ex);
}
}
}
}
以下是我已经尝试过的内容:
还有其他陷阱吗?我使用的是开发指南,而不是以前的SDK,因此对我来说有点新。
从代码中可以看到。我只是在追踪。实例化跟踪器后,我进行了跟踪写,甚至没有实现。
还请注意,即时消息按需运行以测试执行情况。