0

I using content editor web-part to show Task from a task list, using CSS, JScript and Jquery.

Need to apply a filter on the outcome to show the task assigned by and assign to current user(login user).

I tired using Jquery but no luck, can any how I can achieve this using Jquery or other script!

Following are the current script:

<script type="text/javascript">

      jQuery(document).ready(function($) {

         var tasklist = "DailyTask"; // Name of the list that contains task
         var taskTitleField = "Title"; //Name of the text field that has task title
         var taskDescriptionField = "Body"; //Name of the text field that has task description

        MyTasks(tasklist,taskTitleField,taskDescriptionField);
     });


   function MyTasks(tasklist,taskTitleField,taskDescriptionField) {

        //query to retrieve all items
        var query = "<Query><Where><Neq><FieldRef Name='ID' /><Value Type='Number'></Value></Neq></Where><OrderBy><FieldRef Name='DueDate' Ascending='TRUE' /></OrderBy></Query>";

        //return fields for task title and Description
        var camlViewFields = "<ViewFields><FieldRef Name='"+taskTitleField+"' /><FieldRef Name='"+taskDescriptionField+"' /><FieldRef Name='Title' /><FieldRef Name='StartDate' /><FieldRef Name='DueDate' /></ViewFields>";

       $().SPServices({
             operation: "GetListItems",
             async: true,
             listName: tasklist,
             CAMLViewFields: camlViewFields,
             CAMLQuery: query,
             completefunc: function(xData, Status) {
                  $(xData.responseXML).SPFilterNode("z:row").each(function() {
                  var slideContent = ($(this).attr("ows_"+taskTitleField));
                  var Desc = ($(this).attr("ows_"+taskDescriptionField));
                  Desc=Desc.substring(0, 120);
                   var NewsDate = ($(this).attr("ows_DueDate"));
                   var NewsURL = "SITE URL/Lists/DailyTask/DispForm.aspx?ID="+($(this).attr("ows_ID"));

                   NewsURL=NewsURL.split(",")[0];
                   var Link="<a class=\"Nlink\" href=\""+NewsURL+ "\" target='_blank' >"+slideContent+"</a>";
                   //alert(Link);
                  //create slide (li) and append it to other slides
                 $("#MyTasks").append("<span style='height:70px;'>"+Link+" | <font class=\"Ndate\"> "+NewsDate+"</font> </span><div class=\"NewText\"> "+Desc+"</div>");
             }); // end completefunc

          }
        }); // end SPServices call
    }
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.