I am using Microsoft Dynamics CRM Online.
I have a working plug-in starting on the Create Message (post-operate) of an entity called (let's simplify) "entity1". One of the features of this plug-in is that it determines a certain value. Let's call this one "importantValue". The plug-in also creates a relation between "entity1" and another entity (let's simplify again) "entity2", and populates the corresponding lookup field in "entity1".
All of this is working just fine. However, I also want the plug-in to set a field of "entity2" (called "samplefield") to the value of "importantValue". I know how to retrieve the GUID of the related record of entity2, but I can't get the plug-in to update this (already existing) record.
This is the part of the code making problems. I already retrieved the GUID "entity2Guid" and filled importantValue (it's a string). My IOrganizationService is called "service".
Entity entity2 = new Entity("new_entity2");
entity2.Id = new Guid (entity2Guid);
entity2["new_samplefield"] = importantValue;
service.Update(entity2);
What am I doing wrong? Thanks in advance!