1

联系人 (contact) 和汽车详细信息 (cir_cardetails) 之间曾经存在 1:N 关系 - 我现在传递了联系人的参数作为汽车详细信息的查找,如下所示

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 值(查找)设置为汽车详细信息记录,然后创建汽车详细信息记录。我在上面的代码中做的对吗

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

DynamicEntity cardetails = new DynamicEntity("cir_cardetails");

cardetails["cir_carsdetailsid"] = lookup;

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

4

0 回答 0