Retrieve Custom attributes using Dynamic entity RRS feed

  • Question

  •  CrmAuthenticationToken token = new CrmAuthenticationToken();
                token.AuthenticationType = 0;
                token.OrganizationName = "Mycompany;
                CrmService service = new CrmService();
                service.UseDefaultCredentials = true;
                service.CrmAuthenticationTokenValue = token;
                service.Url = string.Format("http://....../2007/CrmService.asmx");
     if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Moniker)
                    // Obtain the target entity from the input parmameters.
                    Moniker entity = (Moniker)context.InputParameters["Target"];
                    if (entity.Name == "contact")
                        Guid contactGuid = entity.Id;
                        TargetRetrieveDynamic retriveTarget = new TargetRetrieveDynamic();
                        retriveTarget.EntityId = contactGuid;
                        retriveTarget.EntityName = EntityName.contact.ToString();
                        RetrieveRequest retrieveRequest = new RetrieveRequest();
                        retrieveRequest.ColumnSet = new AllColumns();//new ColumnSet(new string[] { "new_postaladdress", "fullname" });
                        retrieveRequest.ReturnDynamicEntities = true;
                        retrieveRequest.Target = retriveTarget;
                        RetrieveResponse retrieveResponse = (RetrieveResponse)service.Execute(retrieveRequest);
                        DynamicEntity DynContact = (DynamicEntity)retrieveResponse.BusinessEntity;
                        //DynamicEntity entityContact = (DynamicEntity)service.Retrieve(.Retrieve(EntityName.contact.ToString(), contactGuid, new AllColumns());
                        if (DynContact.Properties.Contains("new_postaladdress"))
                            DynContact.Properties["new_postaladdress"] = "kjdsafkdsajfsaj";
    I am using the above code to get the custom attribute called "new_postaladdress" but it is not working at most i get about 48 attributes back which is way less than exists in Contact entity. for some reason it is not finding all my custom attributes. is there something i am missing? 
    I have checked the other links with similar issues and i am unable to solve it.
    Monday, August 1, 2011 7:55 AM


All replies