Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Plugin development: Entity images doesn't work

$
0
0

Hey,

I'm developing a plugin for MS Dynamics CRM 2011 online. It's a plugin that is triggered when my custom entity (opportunity service) is updated. It's Post-operation plugin. I'm also sure that images that I've registered has all necessary fields available.Alias names in my code are also correct. But no matter what I still get "Key not found in dictionary" error.

Here's part of my code

else if (formState(context) == 2)
                    {
                        Entity preUpdateEntity = (Entity)context.PreEntityImages["OpportunityServicePreImage"];
                        Entity postUpdateEntity = (Entity)context.PostEntityImages["OpportunityServicePostImage"];

                        if (preUpdateEntity.Attributes.Contains("mpc_startprice") && postUpdateEntity.Attributes.Contains("mpc_startprice"))
                        {
                            Money preUpdateValue = (Money)preUpdateEntity["mpc_startprice"];
                            Money postUpdateValue = (Money)postUpdateEntity["mpc_startprice"];

                            // If value has changed
                            if (preUpdateValue.Value != postUpdateValue.Value)
                            {

                                Money oldValue = (Money)opportunity["mpc_estoneoffinvoicing"];
                                Money valueToBeAdded = new Money(postUpdateValue.Value - preUpdateValue.Value);
                                opportunity["mpc_estoneoffinvoicing"] = new Money(oldValue.Value + valueToBeAdded.Value);

                            }
                        }
                    }

I did some research and my code seems to crash at this part: Entity preUpdateEntity = (Entity)context.PreEntityImages["OpportunityServicePreImage"];

But as I said, I'm 99% sure that alias name is correct. Also every tutorial I've seen tells me to do it that way.

I'm sorry for such a shot message. I'll come back later but if any of you would have any valid points please.

Thanks


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>