码迷,mamicode.com
首页 > 其他好文 > 详细

SharePoint - CAML

时间:2014-10-29 16:25:44      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   ar   sp   div   on   

1. CAML是顺序操作,如果要实现类似 “A or B or C or D” 的结果,最好写成 “(((A or B) or C) or D)”的形式,但写成 “((A or B) or (C or D))” 也可以正常工作;

2. CAML中对时间操作时,时间格式为 “yyyy-MM-ddTHH:mm:ssZ”,需要注意T和Z都需要大写,例如:2014-10-29T14:45:00Z;

3. 以下代码用于检测当前时间段内的会议室是否已被预订:

bubuko.com,布布扣
var camlQuery = new SP.CamlQuery();
            var queryXML= "<View><Query>" +
                            "<ViewFields>" +
                                "<FieldRef Name=‘Title‘ />" +
                                  "<FieldRef Name=‘EventDate‘ />" +
                                  "<FieldRef Name=‘EndDate‘ />" +
                                  "<FieldRef Name=‘Meeting_x0020_Room‘ />" +
                                  "<FieldRef Name=‘ID‘/>" +
                           "</ViewFields>" +
                           "<Where>" +
                              "<And>" +
                                  "<Or>" +
                                      "<Or>" +
                                        "<Or>" +
                                            "<And>" +
                                                "<Leq>" +
                                                    "<FieldRef Name=‘EventDate‘ />" +
                                                    "<Value Type=‘DateTime‘ IncludeTimeValue=‘TRUE‘>" + startDateTime +"</Value>" +
                                                "</Leq>" +
                                                "<Gt>" +
                                                    "<FieldRef Name=‘EndDate‘ />" +
                                                    "<Value Type=‘DateTime‘ IncludeTimeValue=‘TRUE‘>"+ startDateTime +"</Value>" +
                                                "</Gt>" +
                                            "</And>" +
                                            "<And>" +
                                                "<Lt>" +
                                                    "<FieldRef Name=‘EventDate‘ />" +
                                                    "<Value Type=‘DateTime‘ IncludeTimeValue=‘TRUE‘>"+ endDateTime +"</Value>" +
                                                "</Lt>" +
                                                "<Geq>" +
                                                    "<FieldRef Name=‘EndDate‘ />" +
                                                    "<Value Type=‘DateTime‘ IncludeTimeValue=‘TRUE‘>"+ endDateTime +"</Value>" +
                                                "</Geq>" +
                                            "</And>" +
                                        "</Or>" +
                                        "<And>" +
                                            "<Geq>" +
                                               "<FieldRef Name=‘EventDate‘ />" +
                                               "<Value Type=‘DateTime‘ IncludeTimeValue=‘TRUE‘>"+ startDateTime +"</Value>" +
                                            "</Geq>" +
                                            "<Leq>" +
                                               "<FieldRef Name=‘EndDate‘ />" +
                                               "<Value Type=‘DateTime‘ IncludeTimeValue=‘TRUE‘>"+ endDateTime +"</Value>" +
                                            "</Leq>" +
                                        "</And>" +
                                    "</Or>" +
                                    "<And>" +
                                        "<Leq>" +
                                           "<FieldRef Name=‘EventDate‘ />" +
                                           "<Value Type=‘DateTime‘ IncludeTimeValue=‘TRUE‘>"+ startDateTime +"</Value>" +
                                        "</Leq>" +
                                        "<Geq>" +
                                           "<FieldRef Name=‘EndDate‘ />" +
                                           "<Value Type=‘DateTime‘ IncludeTimeValue=‘TRUE‘>"+ endDateTime +"</Value>" +
                                        "</Geq>" +
                                    "</And>" +
                                 "</Or>" +
                                 "<Eq>" +
                                    "<FieldRef Name=‘Meeting_x0020_Room‘ />" +
                                    "<Value Type=‘Lookup‘>"+ meetingRoom +"</Value>" +
                                 "</Eq>" +
                              "</And>" +
                           "</Where>" +
                           "</Query></View>";
            camlQuery.set_viewXml(queryXML);
            this.collListItem = oList.getItems(camlQuery);
View Code

4. 

SharePoint - CAML

标签:style   blog   http   color   os   ar   sp   div   on   

原文地址:http://www.cnblogs.com/qijiage/p/4059462.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!