代码之家  ›  专栏  ›  技术社区  ›  aminvincent

如何通过插件C使用lookup CRM 365插入数据#

  •  0
  • aminvincent  · 技术社区  · 7 年前

    我查了一下“ 新建_lookuptransactionheader “在我的实体中” “。此查找链接自” 新建事务标头 “实体。如何使用c#crm插件插入数据?

    public void InsertDataUsingLookup(XrmServiceContext xrm, Entity entitiy, ITracingService tracer)
    {
        new_trialxrmservicetoolkit trial = new new_trialxrmservicetoolkit();
        trial.new_name = "testplugin";
        trial.new_LookupTransactionHeader = null; //this is i don't know how to get value from new_LookupTransactionHeader
        trial.new_Notes = "this is test plugin using c#";
        xrm.AddObject(trial);
        xrm.SaveChanges();
    }
    

    我更新了mycode并解决了这个问题:

    public void InsertDataUsingLookup(XrmServiceContext xrm, Entity entitiy, ITracingService tracer)
        {
            new_trialxrmservicetoolkit trial = new new_trialxrmservicetoolkit();
            trial.new_name = "testplugin";
            trial.new_LookupTransactionHeader = new EntityReference("new_transactionheader", Guid.Parse("5564B5F0-0292-E711-8122-E3FE48DB937B"));
            trial.new_Notes = "this is test plugin using c#";
            xrm.AddObject(trial);
            xrm.SaveChanges();
        }
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Arun Vinoth-Precog Tech - MVP    7 年前
    trial.Attributes["new_LookupTransactionHeader"] = new EntityReference("new_transactionheader", new_transactionheaderId-GUID);
    

    你必须使用 EntityReference