如何将查找值设置为N:1关系记录,然后创建它

时间:2013-04-06 13:30:36

标签: dynamics-crm crm dynamics-crm-4 workflow-activity

联系人(联系人)和汽车详情(cir_cardetails)之间有一个1:N的关系 - 我现在已经将一个参数传递给Contact作为汽车详细信息的查找,如下所示

public static DependencyProperty ContactProperty =   
DependencyProperty.Register("Contact", typeof(Lookup), typeof(CreateCardetails));

 [CrmInput("Contact ID")]
    [CrmReferenceTarget("contact")]
    public Lookup Contact
    {
        get
        {
            return (Lookup)base.GetValue(ContactProperty);
        }
        set
        {

            base.SetValue(ContactProperty, value);
        }
    }

protected override ActivityExecutionStatus Execute(ActivityExecutionContext  
executionContext)
    {

    ----------------------

     ---------------------

      ---------------------

       Guid contactId = ((Lookup)base.GetValue(ContactProperty)).Value;

    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);



}

但是现在我想将此GUID值(查找)设置为Car详细记录,然后创建Car详细记录。是不是我在上面的代码中做了

Lookup lookup = new Lookup();
lookup.Value = contactId;
lookup.type = "contact";

DynamicEntity cardetails = new DynamicEntity("cir_cardetails");

cardetails["cir_carsdetailsid"] = lookup;

请帮助我如何设置查找值。

0 个答案:

没有答案