I did a build for a custom wf assembly in VS 2017.
The following is my code. There is no red squigglies and registered without error:
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);
}
}
}
}
The following is what I already attempted:
- Recompiled to .NET 8.5.2
- Ensured targeting core assemblies to correct version of d365 v9 online
Is there any other gotchas? Im using dev guide rather than previous SDK so this is a bit new to me.
As you can see from code. I am just tracing. I threw a trace write after instanciating tracer and doesn't even get to that.
Also note, Im running this on-demand to test execution.