I have one Date and time column and text colum. I need to retrieve list item value based on this both column using CAML query..
For ex:
Columname---> Date value for date would be-6/1/2013 and another date would be 6/3/2013
Columnname-> Team Value for Team would be -A
I could not able to install U2u Builder in my machince. My CAML query as mentioned below
<Where><And><Eq><FieldRef Name='Team' /><Value Type='Text'>PP</Value></Eq><Gt><FieldRef Name='Date' /><Value IncludeTimeValue='False' Type='DateTime'>6/1/2013</Value></Gt><Lt><FieldRef Name='Date' /><Value IncludeTimeValue='False' Type='DateTime'>6/2/2013</Value></Lt></Eq></And></Where>
Please can any one give Correct CAML query for this condition. i am going to get the values in javascript.
#<script type="text/javascript">ExecuteOrDelayUntilScriptLoaded(MainFunction, "sp.js");
function MainFunction() {
var myQueryString = "<Where><And><Eq><FieldRef Name='Team' /><Value Type='Text'>PP</Value></Eq><Gt><FieldRef Name='Date' /><Value IncludeTimeValue='False' Type='DateTime'>6/1/2013</Value></Gt><Lt><FieldRef Name='Date' /><Value IncludeTimeValue='False' Type='DateTime'>6/2/2013</Value></Lt></Eq></And></Where>";
var myContext = new SP.ClientContext.get_current(); ;
var myWeb = myContext.get_web();
var myList = myWeb.get_lists().getByTitle("as");
var myQuery = new SP.CamlQuery();
myQuery.set_viewXml(myQueryString);
myItems = myList.getItems(myQuery);
myContext.load(myItems, 'Include(ID,Title,Tower)');
myContext.executeQueryAsync(Function.createDelegate(this, GetListDataSuccess), Function.createDelegate(
this, GetListDataFail));
//alert('Query started, but not yet finished!');
}
function GetListDataFail(sender, args) {
// Show error message
alert('GetListDataFail() failed:' + args.get_message());
}
function GetListDataSuccess(sender, args) {
var currListItemCount = myItems.get_count();
//alert(currListItemCount + ' Items found!');
var currItemEnumerator = myItems.getEnumerator();
var currItemDetails = '';
// Loop through all items
while (currItemEnumerator.moveNext()) {
// Get current item
var currItem = currItemEnumerator.get_current();
// Concatenate values
if (currItemDetails == "")
currItemDetails = currItem.get_item("Tower");
else
currItemDetails = currItemDetails + ';' + currItem.get_item("Tower");
}
// Show details
//alert(currItemDetails);
callCombo(currItemDetails);
}
function addValuetoCombo(txtvalue, ddl) {
var option = document.createElement("option");
option.text = txtvalue;
option.value = txtvalue;
try {
ddl.add(option, null); //Standard
} catch (error) {
alert('error');
ddl.add(option); // IE only
}
}
function callCombo(msg) {
var str_array = msg.split(';');
var combo = document.getElementById("ddlbox");
//alert(msg);
for (var i = 0; i < str_array.length; i++) {
// Trim the excess whitespace.
//alert(str_array[i]);
var objText = str_array[i];
// Add data to dropdown
addValuetoCombo(objText, combo);
//alert(i);
}
}
</script>