Posts

Showing posts from 2019

Dynamics CRM 365 Error 'The Given Key is not present in dictionary'

As a Dynamics CRM developer we always come across the error saying that 'The Given Key is not present in dictionary'. The reason we receive this error message because of below issues:- When we try to get the attribute value from Entity object without checking the attribute. String AccountNumber=objAccount["accountnumber"];   The above line will throw error if ObjAccount doesn't contains this attributes.  TO fix this we should always check attributes in Entity object then get the value. Resolution: if(objAccount.attributes.contains("accountnumber")) String AccountNumber=objAccount["accountnumber"];            We can also use below code which will return null if attribute is not present in Entity object. string AccountNumber=objAccount.GetAtrributeValue<String>("accountnumber"); Happy CRMing!