I have two custom entities called "entity1" and "entity2".
In "entity1", there's a lookup field connecting it to "entity2". Now, I just want to use a plug in to fill in this lookup field when I create a new record of "entity1". To make things simpler, let's say I want to connect every new record of "entity1" with an already existing record in "entity2". And let's say the name of this record in "entity2" is "sampleName".
I'm not that experienced with plug ins, and I can't figure out how to make this work. I guess I need to use this line of code below somehow, but I have a problem with retrieving the correct GUID. How do I do this? And is there something else I have to include in my code?
entity1["new_lookup"] = new EntityReference("entity2", neededID);
The plugin itself does some other stuff too, and it's all working. I just can't seem to get past this lookup-field problem. I'm using Microsoft Dynamics CRM Online 2016 by the way.
Thanks in advance for your help!