SharePoint Caml query Calculated Fields

本文详细解析了在SharePoint中使用CAML查询计算字段时遇到的值类型匹配问题,提供了正确的解决方法并展示了如何通过代码获取字段的实际值类型。

Do you have Problems with the SPSiteDataQuery (CAML) query  of Sharepoint
computed Fields. You are running in an Error or recive an empty DataTable ?
Normaly you think your query must be  correct because it looks  exactly like this:

<Query>
 <Where>
   <Eq>
     <FieldRef Name='MyComputed' />
     <Value Type='Computed'>111</Value>
   </Eq>
 </Where>
</Query

Haha, yes my friend, you are realy not alone with this problem on the planet.

It seems to be the logical solution for the correct caml querry,
but the value type is saved in the format it is determined
in the Computet Field, So  is the field of the Type Text, or Integer ?
Than the query must look like this:

<Query>
 <Where>
   <Eq>
     <FieldRef Name='MyComputed' />
     <Value Type='Number'>111</Value>
   </Eq>
 </Where>
</Query>

You can get the correct ValueType of the field with -> ((SPFieldCalculated)field).OutputType.ToString();

Please also note this. The Value defined for the coloumn has to match the ValueType that is expected with the formula !

For Example: The Result of (Column1+Column2)  is interpreted by Sharepoint as Number
so the ValueType must be Number
For Example: The Result of =Concatanate([Column1][Column2])  is interpreted by Sharepoint as Text
so the ValueType must be Text

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值