Answered by:
Having problems with DynamicEntity in crm 4.0

Question
-
Hello everyone,
I am trying to update a custom entity through a plug-in in CRM 4. Since it is a custom entity, I can't retrieve it with the ICrmService Retrieve method, so I tried using DynamicEntity with the help of this article:
http://nishantrana.wordpress.com/2008/10/29/understanding-dynamicentity-in-microsoft-dynamic-crm/
This is my code snippet which creates the DynamicEntity with an existing entity's guid (CustomEntityId), and sets a contact lookup field before update. Unfortunately it returns with "unable to process request", and I wasn't able to find the cause of it. Any help would be appreciated.
DynamicEntity MyEntity = new DynamicEntity("new_myentity"); MyEntity.Properties.Add(new KeyProperty("new_myentityid", new Key(new Guid(CustomEntityId)))); MyEntity.Properties.Add(new LookupProperty("new_contact", new Lookup("contact", ContactId))); _service.Update(MyEntity);
Tuesday, March 26, 2013 2:16 PM
Answers
-
Sorry for wasting your time, I found my mistake. I had two similar entities, and set the dynamic entity name to the wrong one.
Thanks for the help anyway.
- Marked as answer by Adam Borsik Wednesday, March 27, 2013 9:25 AM
Wednesday, March 27, 2013 9:25 AM
All replies
-
Hi,
Can you give us a little more detail? How are you performing the request?
Are you doing a service.Update(MyEntity) type of call?
Have you tried using an UpdateRequest through service.Execute?
If you haven't, try some thing like:
TargetUpdateDynamic target = new TargetUpdateDynamic(); target.Entity = MyEntity; UpdateRequest req = new UpdateRequest(); req.Target = target; service.Execute(req);
Does the same thing happens?
Regards, João
Tuesday, March 26, 2013 4:06 PM -
Hi Joao,
Thank you for your response. Yes, I used a service.Update call in the original code. I tried your code, unfortunately it resulted in the same error. If you have any other ideas, I'm open to suggestions.
Wednesday, March 27, 2013 9:08 AM -
Sorry for wasting your time, I found my mistake. I had two similar entities, and set the dynamic entity name to the wrong one.
Thanks for the help anyway.
- Marked as answer by Adam Borsik Wednesday, March 27, 2013 9:25 AM
Wednesday, March 27, 2013 9:25 AM