Answered by:
cannot get id from update in plugin

Question
-
i am getting key not found in dictionary when trying to retrieve id in an update. i've registered post image in reg tool. this line works find in create message but not in my update code. any suggestion?
portalId= ((Guid)context.OutputParameters.Properties["id"]);
Tuesday, November 15, 2011 3:30 PM
Answers
-
Oh, so you are using 4.0... makes a bit more sense now.
Check this out:
http://asadewa.wordpress.com/2008/05/21/crm-40-plug-in-getting-entity-id-is-it-just-me-or/
Jamie Miley
Check out my about.me profile!
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!- Proposed as answer by Jamie MileyModerator Tuesday, November 15, 2011 4:30 PM
- Marked as answer by ginger_1921 Tuesday, November 15, 2011 5:03 PM
Tuesday, November 15, 2011 4:30 PMModerator
All replies
-
The ID shouldn't change on an update so does this work:
public void Execute(IServiceProvider serviceProvider) { //Extract the tracing service for use in debugging sandboxed plug-ins. ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService)); // Obtain the execution context from the service provider. IPluginExecutionContext context = (IPluginExecutionContext) serviceProvider.GetService(typeof(IPluginExecutionContext)); // The InputParameters collection contains all the data passed in the message request. if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { // Obtain the target entity from the input parmameters. Entity entity = (Entity)context.InputParameters["Target"];
Then just examine the entity.Id property.
Jamie Miley
Check out my about.me profile!
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!
- Edited by Jamie MileyModerator Tuesday, November 15, 2011 3:46 PM
Tuesday, November 15, 2011 3:45 PMModerator -
hey, but even if id doesn't change how do i get access to it? i also tried:
DynamicEntity postImageID = (DynamicEntity)context.PostEntityImages.Properties["PostImage"]; portalId= ((Guid)postImage.Properties["id"]);
- Edited by ginger_1921 Tuesday, November 15, 2011 4:04 PM
- Marked as answer by ginger_1921 Tuesday, November 15, 2011 4:52 PM
- Unmarked as answer by ginger_1921 Tuesday, November 15, 2011 5:03 PM
Tuesday, November 15, 2011 3:57 PM -
Oh, so you are using 4.0... makes a bit more sense now.
Check this out:
http://asadewa.wordpress.com/2008/05/21/crm-40-plug-in-getting-entity-id-is-it-just-me-or/
Jamie Miley
Check out my about.me profile!
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!- Proposed as answer by Jamie MileyModerator Tuesday, November 15, 2011 4:30 PM
- Marked as answer by ginger_1921 Tuesday, November 15, 2011 5:03 PM
Tuesday, November 15, 2011 4:30 PMModerator -
thanksTuesday, November 15, 2011 4:52 PM
-
I am confused. You marked a response that failed earlier as the answer but didn't also mark any of my responses as helpful or also as answers. Did none of them help you? What was the root of this problem?
Jamie Miley
Check out my about.me profile!
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!Tuesday, November 15, 2011 4:57 PMModerator -
my apologies - corrected :P
that link you sent was useful.
thanks again.
Tuesday, November 15, 2011 5:04 PM -
Tuesday, November 15, 2011 5:11 PMModerator