Skip to main content
1-Visitor
June 27, 2017
Question

Unable to filter infotable inside foreach/for loop ?

  • June 27, 2017
  • 2 replies
  • 2675 views

Hi,

We have two infortables

infotable1 contains 50 records

infotable2 contains 3 records we want to get maching records of all in for each way. Please find below logic we have written

var tableLength = infotable1 .rows.length;

   

    for(var z = 0; z < tableLength; z++)

    {

       

        var row=infotable1.rows;

       

var params = {

     fieldName: "source_number" /* STRING */,

      isCaseSensitive: undefined /* BOOLEAN */,

      t: infotable2 /* INFOTABLE */,

      value: row.source_number /* STRING */   // If I pass this I am getting empty result if I pass hardcoded value it works fine

   };

   // result: INFOTABLE

  var result = Resources["InfoTableFunctions"].EQFilter(params);

       

    }

Colud you check is anything worng in my code?

Thanks

Anil Kesana

    2 replies

    1-Visitor
    June 27, 2017

    Try Intersect Snippet instead

    akesana1-VisitorAuthor
    1-Visitor
    June 27, 2017

    Hi Carles,

    Thanks for your quick response, I have tried but not worked source_number in both table is string.

    we need to filter based on that string field of every row of infotable1 and get matcing row of infotable2

    Thanks

    Anil Kesana

    1-Visitor
    June 28, 2017

    Hi Anil,

    With Intersect snippet you will need something like:

    var result = Resources["InfoTableFunctions"].Intersect({

      columns1: "",

      columns2: "*",

      joinType: "INNER",

      t1: infotable1,

      t2: infotable2,

      joinColumns1: "source_number",

      joinColumns2: "source_number"

    });

    akesana1-VisitorAuthor
    1-Visitor
    June 30, 2017

    Hi Carles,

    Thanks Carles, It  worked for me I would like to check and condition on multiple columns is is it  possible like below?

    1. var result = Resources["InfoTableFunctions"].Intersect({ 
    2.   columns1: ""
    3.   columns2: "*"
    4.   joinType: "INNER"
    5.   t1: infotable1, 
    6.   t2: infotable2, 
    7.   joinColumns1: "source_number"&&"plant_id"&&"note_id"
    8.   joinColumns2: "source_number"&&"plant_id"&&"note_id"
    9. }); 

    I got weird result when execute the above the code, how to check and condition ?

    Thanks,

    Anil Kesana

    1-Visitor
    June 30, 2017

    Separate columns by commas