1 Reply Latest reply on Sep 15, 2017 10:09 AM by polinao RSS
    mberber-2 Newbie

    How to compare two InfoTable or DataTable Values and find missing value?

    Hello Everyone ;

     

    In our project there are two DataTable. Both have services which output as InfoTable. We can call them testData and raspiData. Normally this two table must be have equal data. But when it doesnt i want to know which row is missing.

     

    testData                                                                                                                                                                                                       raspiData

    result data

     

     

    My service wont work properly. I dont know where i wrong. It should be list only Barcode "1005" because it isnt in the other table.

     

    var testData = Things["testDT"].Select();
    var raspiData = Things["RaspiData"].Select();
    
    //-----------------------------------------------------------
    
    var params = {
    infoTableName : "InfoTable",
    dataShapeName : "testDS"
    };
    
    var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
    //--------------------------------------------------
    var tableLength = testData.rows.length;
    for (var x = 0; x < tableLength; x++) {
    var row = testData.rows[x];
      
            var tableLength2 = raspiData.rows.length;
                for (var y = 0; y < tableLength2; y++) {
                    var row2 = raspiData.rows[y];
    
       if(row.Barcode != row2.Barcode){             
                   
    var newEntry = new Object();
                   
                    newEntry.Barcode   = row.Barcode;
                    newEntry.ProdID    = row.ProdID;
                    newEntry.StationID = row.StationID;
    
         result.AddRow(newEntry);      
    
       }
       }         
    }
    

     

    Any help will be appreciated.

     

    Thank you.