Check out the latest Sales updates!Learn about the key capabilities and features of Dynamics 365 Sales and experience some of the new features.
Download overview guide | Watch Sales video
2020 release wave 1 Discover the latest updates and new features to Dynamics 365 planned through September 2020
Release overview guides and videos Release Plan | Preview 2020 Release Wave 1 Timeline
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
I'm facing issue while fetching data from a lookupup field using a plugin : "An exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll but was not handled in user code"
I tried below methods for all i get the same error
var lookupid= ((EntityReference)(entity.Attributes["simid"])); var lookup= service.Retrieve(lookupid.LogicalName, lookupid.Id, new ColumnSet(true));
EntityReference sim = ((EntityReference)entity.Attributes["vssm_simid"]); Guid simId = sim.Id;
Guid simId = ((EntityReference)entity.Attributes["vssm_simid"]).Id;
Before applying the methods, you can place an if check as follows :-
if (entity.Attributes.Contains("<attribute name">)
If this check passed then you can adopt the statement as follows :-
EntityReference obj = (EntityReference)entity.Attributes["<attribute name>"];
As per the error it seems that you are not checking the proper schema name or it is not coming in the plugin context.
Action plan :-
- You can check whether the attribute belongs to the same entity where plugin is registered.
- Check the schema name of the lookup field which you want to retrieve the value
- Above if condition will help you to check for the same.
Hope this helps.
Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.
The field is in the same entity where the plugin is regiestered and the field schema name is also correct.
But when i put the if condition: if (entity.Attributes.Contains("vssm_simid")) it is coming out of the loop.
Business Applications communities