Link to home
Start Free TrialLog in
Avatar of Trevor Helps
Trevor Helps

asked on

Retrieved custom entity properties are not returned when they're empty (V4.0)

My webservice retrieves custom CRM entities and decides if certain properties need to be updated from an external source. It seems that whenever properties in CRM are empty (certainly string properties - I've yet to test other property types) they aren't returned in my DynamicEntity. My logic is being driven by properties returned and decides what needs to be updated, so any empty string properties never get updated! See snippet. Thanks for any advice/suggestions.
Dim query As New QueryExpression
query.EntityName = "my_entity"
query.ColumnSet = New AllColumns
Dim condition1 As New ConditionExpression
condition1.AttributeName = sExistingEntityKey
condition1.Operator = ConditionOperator.Equal
condition1.Values = New String() {sLookupKey}
Dim childFilter As New FilterExpression
childFilter.FilterOperator = LogicalOperator.And
childFilter.Conditions = New ConditionExpression() {condition1}
query.Criteria = childFilter
Dim retrieve As New RetrieveMultipleRequest()
retrieve.Query = query
retrieve.ReturnDynamicEntities = True
Dim retrieved As RetrieveMultipleResponse = CType(crmServ.Execute(retrieve), RetrieveMultipleResponse)
If retrieved.BusinessEntityCollection.BusinessEntities.Length > 0 Then
   Dim entity As New DynamicEntity
   Dim retrievedEntity As DynamicEntity = CType(retrieved.BusinessEntityCollection.BusinessEntities(0), DynamicEntity)
   For i = 0 To retrievedEntity.Properties.Length - 1
      If retrievedEntity.Properties(i).Name = "[property name I know must be updated]" Then
      update property...
      crmServ.Update(retrievedEntity)
and so on...

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Biffster007
Biffster007
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Trevor Helps
Trevor Helps

ASKER

I'd been hunting for an obscure property or method that might return ALL columns regardless of content but I'll now follow your suggestion! Thanks.