简体   繁体   中英

Dynamics 365 default value in FetchXML

Is there anyway I can receive a default value in Fetch XML queries

For example <attribute name="fullname" />

If in the entity "fullname" is not set in dynamics currently it's not returning the attribute. Is there any way I can receive blank in the result set?

I am using EntityCollection collection = svc.RetrieveMultiple(new FetchExpression(body.ToString()));

I don't want to check for the attribute, don't want to hardcode, in the code as it can be any attribute.

This is usual and expected behavior. Just we have to check for existence and availability like below:

if (entity.Contains("fullname") && entity.GetAttributeValue<String>("fullname") != null)
{

//your logic here

}

In your iteration of EntityCollection using foreach , use the above check for every attribute of its datatype.

Assuming you're setting your ColumnSet to All/true.

You can query all the entity attributes separately from the metadata using the RetrieveEntityRequest Make sure to set the EntityFilter to Attributes This will retrieve all attributes from the metadata for said entity type.

Once you have the list of all existing attributes you can loop check if they exist in the returned entities in your collection if(!entity.contains(att)) => this means the value is null.

Dynamics by default doesn't return the attribute in the collection if its value is null.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM