首页 > 代码库 > SharePoint - CAML
SharePoint - CAML
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. 以下代码用于检测当前时间段内的会议室是否已被预订:
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=http://www.mamicode.com/‘TRUE‘>" + startDateTime +"</Value>" + "</Leq>" + "<Gt>" + "<FieldRef Name=‘EndDate‘ />" + "<Value Type=‘DateTime‘ IncludeTimeValue=http://www.mamicode.com/‘TRUE‘>"+ startDateTime +"</Value>" + "</Gt>" + "</And>" + "<And>" + "<Lt>" + "<FieldRef Name=‘EventDate‘ />" + "<Value Type=‘DateTime‘ IncludeTimeValue=http://www.mamicode.com/‘TRUE‘>"+ endDateTime +"</Value>" + "</Lt>" + "<Geq>" + "<FieldRef Name=‘EndDate‘ />" + "<Value Type=‘DateTime‘ IncludeTimeValue=http://www.mamicode.com/‘TRUE‘>"+ endDateTime +"</Value>" + "</Geq>" + "</And>" + "</Or>" + "<And>" + "<Geq>" + "<FieldRef Name=‘EventDate‘ />" + "<Value Type=‘DateTime‘ IncludeTimeValue=http://www.mamicode.com/‘TRUE‘>"+ startDateTime +"</Value>" + "</Geq>" + "<Leq>" + "<FieldRef Name=‘EndDate‘ />" + "<Value Type=‘DateTime‘ IncludeTimeValue=http://www.mamicode.com/‘TRUE‘>"+ endDateTime +"</Value>" + "</Leq>" + "</And>" + "</Or>" + "<And>" + "<Leq>" + "<FieldRef Name=‘EventDate‘ />" + "<Value Type=‘DateTime‘ IncludeTimeValue=http://www.mamicode.com/‘TRUE‘>"+ startDateTime +"</Value>" + "</Leq>" + "<Geq>" + "<FieldRef Name=‘EndDate‘ />" + "<Value Type=‘DateTime‘ IncludeTimeValue=http://www.mamicode.com/‘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);
4.
SharePoint - CAML
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。