Personalized Community is here!
Quickly customize your community to find the content you seek.
Have questions on moving to the cloud? Visit the Dynamics 365 Migration Community today! Microsoft’s extensive network of Dynamics AX and Dynamics CRM experts can help.
2022 Release Wave 1 PlanDynamics 365 release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.
2022 release wave 1 plan
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
I have a plugin with following codes:
Guid entityId = Guid.Empty;
….. entity has been created here
entityId = localContext.OrganizationService.Create(entity); //this one is compiled OK, it returns the Guid of the entity,
However, I got compile error if I use the following code:
entityId = localContext.OrganizationService.Update(entity); //the compile time error for this line code shows "Cannot implicitly convert type 'void' to System.Guid, "
Is there anyway to fix this compile time error to get the entity Guid ID above?
Update function doesn’t return any value. In order to update a record, you must know the GUID of the record in advance before calling update function, and set it to entity object as below.
entity.Id = new Guid(“<GUID>”);
Thank you for your quick response, but the thing is that how can I get the "<GUID>"?
Basically, I have the function like this:
Entity HandleUpdate(Entity entity) //here the entity object is passed in
…. then doing some setting like this
entity.Attributes["dev_dateofbirthtext"] = dob.ToString("MM/dd/yyyy");
entity.Id = new Guid(“< GUID >”); //here I need to add your code here, I don't know how to get GUID of the entity passed in.
return entity; //here entity has its GUID which is as same as entity.Id, right?
I just released that since the entity is passed in, so in this case, the entity.Id is already known, right? so basically, the entity.Id is the GUID of the passing in entity,
so basically, my codes where calling this update function needs to use entity.Id.
Can I check whether it is a plug-in or any other .Net application?
Without knowing GUID of the record, we cannot update it. It is like, without knowing address you cannot reach the destination.
When calling HandleUpdate(entity) function, entity object should have already set for it's GUID as in below code.
public void UpdateContactDOB()
// If you do not know the contact record for which you need to update DOB, retrieve it
EntityCollection contactRecords = localContext.OrganizationService.RetrieveMultiple(query);
Entity entity = new Entity("contact");
foreach(Entity contactRecord in contactRecords.Entities)
entity.Id = contactRecord.Id;
Hi Charan, thanks for your help again,
but in my case, the "entity" object is already given and it passes in to the function to be used,
which is same as "contactRecord" in your codes, I am wondering if I need to use RetriveMultiple(query) as your codes?
please see my codes below:
Entity HandleUpdate(Entity entity) // here the entity object is passed in the function
entity.Attributes["dev_dateofbirthtext"] = dob.ToString("MM/dd/yyyy"); //doing these kind of setting
Since calling function would have already passed complete entity object, no need to make retrieve multiple call in HandleUpdate() function. So, entity.Id would give you GUID of the record.
Thank you so much, Charan,
That is what I expected, much appreciated for your quick response, have a great day.
Business Applications communities