Skip to content


Conditionally Empty Entity Reference

Paul asked 6 years ago
Is it possible to handle a lookup (entity reference) when importing to CRM where the source column and, hence, the result, *might* be empty? I can’t manually build the entity reference in a calculation because the CRM SDK assemblies aren’t referenced and trying to build an Entity Reference field type fails with, “Failed to set column xxx to an entity reference column : Unrecognized Guid format,” when the value should actually be null.
Ethan Sorenson Staff answered 6 years ago
Lookup fields cannot be blank. If they are blank, then the lookup will fail and give you an error. A work around would be to have a holding value rather than leaving it blank.
For example, if you are updating a Contact with the Account, but some contacts don’t have an Account for you to associate them with, you will want to create a dummy account that you will map as your value if the source does not contain an account. 
In your mapping you will create a Calculated Column that will check if the source contains a value for account. If it doesn’t, return your dummy account, else return the value in the source. Then map this calculated column to your entity reference.
Nannette replied 5 years ago

How would I handle this if I have to have the value in the source do a lookup for the GUID? The field is either blank or populated with data that I have to perform a lookup on. I am not sure how to get an if/else statement in there.

If you would like to submit an answer or comment, please sign in to the eOne portal.