javascript - Caml Query not executing the where part - Stack Overflow

I am using the below code to query a SharePoint 2010 external listvar targetList = web.get_lists().getB

I am using the below code to query a SharePoint 2010 external list

    var targetList = web.get_lists().getByTitle('Members');
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<view><Query><Where><Eq><FieldRef Name=\'MemberID\'/><Value Type=\'Text\'>mg33</Value></Eq></Where>'+
    '</Query>'+
    '<ViewFields>'+
    '<FieldRef Name=\'MemberID\'/>'+
    '<FieldRef Name=\'Name\'/>'+
    '<FieldRef Name=\'Email\'/>'+
    '<FieldRef Name=\'Department\'/>'+
    '<FieldRef Name=\'Title\'/>'+
    '<FieldRef Name=\'Manager\'/>'+
    '</ViewFields></view>');

    this.collListItem = targetList.getItems(camlQuery);         clientContext.load(collListItem,'Include(MemberID,Name,Email,Department,Title,Manager)');

but the query is retrieving all the list instead of a single record which matches the where statement

I am using the below code to query a SharePoint 2010 external list

    var targetList = web.get_lists().getByTitle('Members');
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<view><Query><Where><Eq><FieldRef Name=\'MemberID\'/><Value Type=\'Text\'>mg33</Value></Eq></Where>'+
    '</Query>'+
    '<ViewFields>'+
    '<FieldRef Name=\'MemberID\'/>'+
    '<FieldRef Name=\'Name\'/>'+
    '<FieldRef Name=\'Email\'/>'+
    '<FieldRef Name=\'Department\'/>'+
    '<FieldRef Name=\'Title\'/>'+
    '<FieldRef Name=\'Manager\'/>'+
    '</ViewFields></view>');

    this.collListItem = targetList.getItems(camlQuery);         clientContext.load(collListItem,'Include(MemberID,Name,Email,Department,Title,Manager)');

but the query is retrieving all the list instead of a single record which matches the where statement

Share asked Feb 21, 2012 at 11:35 SSheblySShebly 2,0731 gold badge21 silver badges29 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Try to look at this MSDN article for example: http://msdn.microsoft./en-us/library/hh185007.aspx

And try the following code. I changed xml element "view" to "View" and .load() method has only one parameter. There is no need for the second one.

var targetList = web.get_lists().getByTitle('Members');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('
<View>
    <Query>
        <Where>
            <Eq>
                <FieldRef Name=\'MemberID\'/>
                <Value Type=\'Text\'>mg33</Value>
            </Eq>
        </Where>'+
    '</Query>'+
    '<ViewFields>'+
        '<FieldRef Name=\'MemberID\'/>'+
        '<FieldRef Name=\'Name\'/>'+
        '<FieldRef Name=\'Email\'/>'+
        '<FieldRef Name=\'Department\'/>'+
        '<FieldRef Name=\'Title\'/>'+
        '<FieldRef Name=\'Manager\'/>'+
    '</ViewFields>
</View>');
this.collListItem = targetList.getItems(camlQuery);
clientContext.load(collListItem);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744931538a4601768.html

相关推荐

  • javascript - Caml Query not executing the where part - Stack Overflow

    I am using the below code to query a SharePoint 2010 external listvar targetList = web.get_lists().getB

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信