• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

165
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?

about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error