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

The given key was not present in the dictionary.Detail:

$
0
0

Hi All,

   I am trying to create and update an entity(an entityReference on the target) and i get an error at the post image entity, my code is below:

f(context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity )
            {
                Entity preconStaffRol = (Entity)context.InputParameters["Target"];
                Entity conStaffRol = (Entity)context.PostEntityImages["image"];

                if (!(conStaffRol.LogicalName == "new_consultantstaffingrole" || conStaffRol.LogicalName == "new_nursestaffingrole")) { return; }
                //if ( conStaffRol.LogicalName != "new_nursestaffingrole") { return; }
                try
                {

                    EntityReference staffRef = conStaffRol.GetAttributeValue<EntityReference>("gg_travelbooking");


                    if (context.MessageName == "Update")
                    {
                        if (staffRef == null)
                        {
                             OptionSetValue conStaff = conStaffRol.GetAttributeValue<OptionSetValue>("new_plandaystatus");
                                                  
                            if (conStaff.Value ==  100000004)
                            {
                               
                                CreateTravelDetail(service, conStaffRol);
                            }
                            else { return; }

                        }
                        else { return; }

                    }

                }
                catch (FaultException<OrganizationServiceFault> ex)
                {
                    throw new InvalidPluginExecutionException($"Unable to create travel Detail entity:  {ex.ToString()}");
                }
                catch(Exception e)
                {
                    tracing.Trace("Error :" + e.ToString());
                    throw;
                }

                
            }

I ma gettong the error at this line : Entity conStaffRol = (Entity)context.PostEntityImages["image"]; 

Error is :

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unexpected exception from plug-in (Execute): TravelPlugins.ComfirmedPlacementPlugin: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.Detail:

Anyone have a glue of what this is, I have checked other similar error online and nothing seems to help.


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images