The week of “just read your mailbox and publish what other smart people found”, continues. Derek Finlinson has the microphone:
Ran into an interesting issue with the Web API and expanding navigation properties today that I thought I would pass along.
I needed to retrieve an attribute from a lookup value related to an entity so ran this lovely query (details changed obviously) (we tried – definitely fake org – t.j.):
$expand=msdyn_workorderincident($select=new_customfield)
It worked great when new_customfield contained data. However, if it was null, the msdyn_workorderincident entity itself came back as null, even though the work order product was in fact related to an incident. To get around this, just make sure to always include the id field in your expanded $select (msdyn_workorderincidentid in this case).
$expand=msdyn_workorderincident($select=new_customfield,msdyn_workorderincident)
That way you still get your expanded entity returned with a null new_customfield. Not sure if this is common knowledge but was new to me. Hopefully it helps someone else out.