<head>
<SCRIPT type=text/javascript src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></SCRIPT>
<SCRIPT type=text/javascript src="http://sample.com/sites/lib/jquery.SPServices-0.7.2.min.js"></SCRIPT>
<title>Filter Replies </title>
</head>
<body>
<table id="BasicTable" border=0 width="55%" align="left"
style="font-family: Verdana;font-size:8pt" >
<tr>
<td style="width:40%;"><B>Reply type :</B></td>
<td style="width:60%;" colspan="2">
<select id="DropStudies" onchange="getComboA(this)"
style="font-family: Verdana;font-size:8pt">
<option value="Low">Low</option>
<option value="Medium">Medium</option>
<option value="High">High</option>
</select>
</td>
</tr>
</table>
<br/><br/>
<table id="myDataTable" border=1 width="55%" align="left" style="font-family: Verdana;font-size:8pt;">
<tr align='left' bgcolor="#00579c">
<td><B>ID</B></td>
<td style="width:40%;"><FONT COLOR="white">
<B>Main Question</B></td>
<td style="width:60%;"><FONT COLOR="white">
<b><B>Reply Details</B></td>
</tr>
</table>
<SCRIPT type=text/javascript>
get() ;
function getComboA(sel)
{
var value = sel.options[sel.selectedIndex].value;
LoadTableFunction();
}
function LoadTableFunction()
{
var table = document.getElementById("myJsonDataTable");
if(table.rows.length >1)
{
for(var i = table.rows.length - 1; i > 0; i--)
{ table.deleteRow(i);}
}
get() ;
}
function get()
{
var method = "GetListItems";
var webURL = $().SPServices.SPGetCurrentSite() ;
var list = "DBExample";
var fieldsToRead = "<ViewFields>" +"<FieldRef Name='Name' />"
+"</ViewFields>";
//----------------------------------------------------------------------------
// GET ALL REPLIES WITH CHOSEN REPLY PRIORITY
// CONTENT TYPE = MESSAGE RETURNS ONLY REPLIES
// CONTENT TYPE = DISCUSSION WILL RETURN THE QUESTIONS.
// THAT IS NOT NEEDED HERE.
// RESURCIVEALL QUERY OPTIONS
//------------------------------------------------------------------------------
var query = "<Query><Where><And><Eq><FieldRef Name='ContentType' />
<Value Type='Text'>Message</Value></Eq>";
query = query +"<Eq><FieldRef Name='Reply_x0020_Priority' />
<Value Type='Choice'>" + DropStudies.value +
"</Value></Eq></And></Where>";
query = query + "<OrderBy><FieldRef Name='ID' Ascending='True' />
</OrderBy></Query>";
var qOptions = "<QueryOptions><ViewAttributes Scope='RecursiveAll'/>
</QueryOptions>";
GetData(method,list,webURL,fieldsToRead,query,qOptions,list);
};
function GetData(method,list,webURL,fieldsToRead,query,qOptions,Folder)
{
$().SPServices
({
operation: method,
async: false,
webURL: webURL,
listName: list,
CAMLViewFields: "<ViewFields Properties='True' />",
CAMLQuery: query,
CAMLQueryOptions: qOptions,
completefunc: function (xData, Status)
{
$(xData.responseXML).SPFilterNode("z:row").each(function()
{
// GET ID OF THE REPLY
//--------------------------------------------
var ID = $(this).attr("ows_ID");
// QUESTION IS n[5].toString()
// LINK TO THE QUESTION IS IN var mainQuestion
//-----------------------------------------------------------
var fileDirRef = $(this).attr("ows_FileDirRef");
var n= fileDirRef.split("/");
var mainQuestion = "http://sample.com/sites/" + n[1].toString() + "/" +
n[2].toString() +"/"+ n[3].toString() +
"/"+ n[4].toString() + "/"+ n[5].toString();
mainQuestion = mainQuestion.replace(/[" "]/g, "%20");
// REMOVE THE REPLY FROM THE OTHER DETAILS IN BODY
//----------------------------------------------------------------------
var QuestionDetail = $(this).attr("ows_Body");
var q = QuestionDetail.split("From");
var q1 = q[0].toString();
// REMOVE THE HORIZONTAL LINE
//-----------------------------------------------
var q2 = q1.split("<hr class=ms-disc-quotedtext>");
// REPLY IS q2[0].toString()
// LINK TO THE QUESTION IS IN var directLink
//--------------------------------------------
var directLink = "http:/sample.com/sites/" + n[1].toString() + "/" +
n[2].toString() +"/"+ n[3].toString() +
"/"+ n[4].toString() + "/DispForm.aspx?ID=" + ID.toString();
directLink = directLink.replace(/[" "]/g, "%20") + "&Source=" + mainQuestion;
var reply = q2[0].toString() + "<a href='" + directLink + "'target=_blank>Link to Reply</a>";
$("#myDataTable").append("<tr align='left'>" +
"<td align='left' valign='top'>"+ID+"</td>" +
"<td align='left' valign='top'>
<a href='" + mainQuestion + "'target=_blank>"
+ n[5].toString() +"</a></td>" +
"<td align='left' valign='top'>"+reply+"</td>" +
"</tr>");
});
}
});
}
</script>
</body>
</html>