How to Insert data using lookup CRM 365 through Plugin C# -
i have lookup "new_lookuptransactionheader" in entity "new_trialxrmservicetoolkit". lookup linked "new_transactionheader" entity. how can insert data using c# crm plugin? mycode:
public void insertdatausinglookup(xrmservicecontext xrm, entity entitiy, itracingservice tracer) { new_trialxrmservicetoolkit trial = new new_trialxrmservicetoolkit(); trial.new_name = "testplugin"; trial.new_lookuptransactionheader = null; //this don't know how value new_lookuptransactionheader trial.new_notes = "this test plugin using c#"; xrm.addobject(trial); xrm.savechanges(); }
i updated mycode , solve:
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 test plugin using c#"; xrm.addobject(trial); xrm.savechanges(); }
trial.attributes["new_lookuptransactionheader"] = new entityreference("new_transactionheader", new_transactionheaderid-guid);
you have use entityreference
above setup lookup attribute.
Comments
Post a Comment