Please help..
I have now registered the assembly and created a workflow also and tried to test it but is not working at all.
My requirement is to create a Car details (cir_cardetails) from Contact (contact) record (N: 1 relationship between Car details and Contact). Passing an input value in the custom workflow. I hoped that everything done well. After workflow is succeeded I checked that car details (mode) has not been created. Nothing has done, I have pasted the entire code on the below of image.
namespace CreateCardetailsRecord
{
//Given a name for the Custom workflow
[CrmWorkflowActivity("Create Cardetails Record", "Utilities")]
public partial class CreateCardetails : SequenceActivity
{
public static DependencyProperty modelProperty = DependencyProperty.Register("model", typeof(CrmNumber), typeof(CreateCardetails));
//This will use as input as highlighted in the image
[CrmInput("Model")]
public CrmNumber model
{
get
{
return (CrmNumber)base.GetValue(modelProperty);
}
set
{
base.SetValue(modelProperty, value);
}
}
public CreateCardetails()
{
InitializeComponent();
}
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
// Get the context service.
IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));
IWorkflowContext context = contextService.Context;
// Use the context service to create an instance of CrmService.
ICrmService crmService = context.CreateCrmService(true);
DynamicEntity entity = null;
Guid contactId;
if (context.InputParameters.Properties.Contains("Target") && context.InputParameters.Properties["Target"] is DynamicEntity)
{
// Obtain the target business entity from the input parmameters. (Getting the GUID of contact record)
entity = (DynamicEntity)context.InputParameters.Properties["Target"];
contactId = ((Key)entity.Properties["contactid"]).Value;
//Creating a lookup for Car Details and setting the GUID of contact
Lookup lookup = new Lookup();
lookup.Value = contactId;
lookup.type = "contact";
//Create an car details record which will be linked to the contact record
DynamicEntity cardetails = new DynamicEntity("cir_cardetails");
cardetails["cir_carsdetailsid"] = lookup;
//Setting the picklist value of Model
Picklist modelPickList = new Picklist();
modelPickList.Value = model.Value;
cardetails.Properties.Add(new PicklistProperty("cir_model",modelPickList));
//Creating the car details record
Guid carkey = crmService.Create(cardetails);
}
return ActivityExecutionStatus.Closed;
}
}
}
I have pasted the entire code, am I missing something to achieve this (Should I need to include something else to make it done). All suggestion/feedback/assistance are welcome.