afternoon,
I have a plugin that needs to verify the contents of 4 fields before sending a SOAP request (for formatting purposes). these are "a_gis_sitename", "a_gis_street", "a_gis_town", "a_gis_postcode". While I appreciate that i can format these client-side, I would prefer to save myself an extra field in my form (it is already a substantial form.)
I have created a post-image with the alias "postImage" of the fields in question and written the following:
string[] siteFields = { "sitename", "street", "town", "postcode" };
string siteDetails = "";
int i = 0;
int isEmpty = 0; // if isEmpty hits 3, the GIS fields haven't been populated.
// now the image of the case needs to be checked to see if fields were empty.
if (context.PostEntityImages.Contains("postImage") && context.PostEntityImages["postImage"] is Entity) {
var postImage = (Entity)context.PostEntityImages["postImage"];
foreach (string f in siteFields) {
// add each field to comma separated list making sure first item in list isn't preceded by comma.
if (postImage.Attributes["a_gis_" + f] != null)
siteDetails += ((i++ > 1) ? ", " : "") + (string)postImage.Attributes["a_gis_" + f];
else isEmpty++;
}
if (isEmpty < 3) siteDetails = "Location of problem: " + siteDetails + ". ";
}
stack trace persistently returns a
The given key was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at myService.Plugins.dogFouling.Execute(IServiceProvider serviceProvider)
Why is this happening. CRM can be such a headache to debug.