简体   繁体   English

FetchXML 中的 Dynamics 365 默认值

[英]Dynamics 365 default value in FetchXML

Is there anyway I can receive a default value in Fetch XML queries无论如何我可以在 Fetch XML 查询中收到一个默认值

For example <attribute name="fullname" />例如<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()));我正在使用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.在使用foreachEntityCollection迭代中,对其数据类型的每个属性使用上述检查。

Assuming you're setting your ColumnSet to All/true.假设您将 ColumnSet 设置为 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.您可以使用RetrieveEntityRequest从元数据中单独查询所有实体属性 确保将 EntityFilter 设置为 Attributes 这将从元数据中为所述实体类型检索所有属性。

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.一旦您拥有所有现有属性的列表,您就可以循环检查它们是否存在于您的集合中返回的实体中 if(!entity.contains(att)) => 这意味着该值为空。

Dynamics by default doesn't return the attribute in the collection if its value is null.默认情况下,如果值为 null,Dynamics 不会返回集合中的属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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