Example of InOut Parameter in custom workflow
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Workflow;
using System;
using System.Activities;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1
{
public class Program : CodeActivity
{
[Input("Value")]
public InArgument<string> Value { get; set; }
[Output("AccountId")]
public OutArgument<string> AccountId { get; set; }
protected override void Execute(CodeActivityContext context)
{
IWorkflowContext wfcontext = context.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(wfcontext.InitiatingUserId);
Entity Contact = service.Retrieve(wfcontext.PrimaryEntityName, wfcontext.PrimaryEntityId, new ColumnSet(""));
if (Contact.Contains("parentcustomerid"))
{
string accounid = (Contact["parentcustomerid"] as EntityReference).Id.ToString();
AccountId.Set(context, accounid);
}
string erfUser = Value.Get<string>(context);
}
}
}
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Workflow;
using System;
using System.Activities;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1
{
public class Program : CodeActivity
{
[Input("Value")]
public InArgument<string> Value { get; set; }
[Output("AccountId")]
public OutArgument<string> AccountId { get; set; }
protected override void Execute(CodeActivityContext context)
{
IWorkflowContext wfcontext = context.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(wfcontext.InitiatingUserId);
Entity Contact = service.Retrieve(wfcontext.PrimaryEntityName, wfcontext.PrimaryEntityId, new ColumnSet(""));
if (Contact.Contains("parentcustomerid"))
{
string accounid = (Contact["parentcustomerid"] as EntityReference).Id.ToString();
AccountId.Set(context, accounid);
}
string erfUser = Value.Get<string>(context);
}
}
}
Comments
Post a Comment