Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

77
Views
How to Use REST Api and javascript conditions to filter listitems

I am trying to filter sharepoint list items using a REST API filter and javascript conditions. When I use == it doesn't work, only if I use !=.

var requestUri = "/_api/web/Lists/GetByTitle('Request For Information')/items?$filter=substringof('" + myQry + "',RFI_nummer)&$orderby=LTIOV asc";

I basically filter the items of which the RFI_nummer contains 2022 and sort them on LTIOV (which is a date field)

then I set further conditions like this:

        $.each(data.d.results, function (i, item){

            var stat = item.MijnStatus;
            var tit = item.Title;
            var start = item.Created.substring(0, 10);
            var LTIOV = item.LTIOV.substring(0, 10);
            var RFInum = item.RFI_nummer;                        
               if (stat !="Completed") {
            var start = parseDate(start);
            var end = parseDate(LTIOV);
                if (end <= today.getTime()) {
                balk_kleur = "ganttRed";
                } else {
                    balk_kleur = "ganttGreen";
                }
            demoSource.push({
                        name: RFInum,
                desc: LTIOV,
                        values: [{
                            from: start,
                            to: end,
                            label: tit,
                            customClass: balk_kleur,
                dataObj: stat
        }],
                });
                                 }
                                                 })   //$.each

function parseDate(input) {
  var str = input.split('-');
  var sDate = Date.UTC(str[0], str[1]-1,str[2]);
  return sDate;
               }

        });

When I try to replace if (stat !="Completed") with if (stat =="In Action") it doesn't give me the right items. What am I doing wrong?

7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs