cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

how to read an infotable having integer value

Jamal8548
11-Garnet

how to read an infotable having integer value

Hello Community,

I am getting the data in an infotable but i am unable to read it.

 

 

const SERVICENAME = "getPieChartDataOnMashup";
logger.info(me.name + " :: " + SERVICENAME + " :: Start Service");

let projectName = me.name.match(/^[^.]*/)[0];

let ab;
try {
     ab = Things["V2.MYSQLDatabaseController"].SQLQuery_GetEntriesForPieChart({
       
        lineName: lineName,
        StartDate:startDate,
        EndDate:endDate

    });
   
    logger.info(ab.rows[0]);
    
} catch (e) {

    logger.error("There is an error in service getPieChartDataOnMashup DataBase service.SQLQuery_GetEntriesForPieChart " + e);

}
 let result = ab;

 

the below pic is for logger ab.rows[0] 

Jamal8548_0-1713425543398.png

the below is the output of the service. i am unable to read in logger ioEntries like ab.rows[0].ioEntries the values is 0 but i am getting undefined. Why? i am getting this data from SQL query and i have set the ouput as an infotable with two fields of number. 

Jamal8548_1-1713425638923.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @ZbigniewK  and @Arun_C 

 

Thanks both of you for your insights. Its actually spelling mistake and sometime thingworx needs to be refresh the service inorder to see effects but yeah its working now. Below is my code also. May be it will be useful for other people.

 

const SERVICENAME = "getPieChartDataOnMashup";
logger.info(me.name + " :: " + SERVICENAME + " :: Start Service");

let projectName = me.name.match(/^[^.]*/)[0];

let AnalysisInfotable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
    infoTableName: "InfoTable",
    dataShapeName: "V2.Analysis.DS"
});

let queryresults;
try {
     queryresults = Things["V2.MYSQLDatabaseController"].SQLQuery_GetEntriesForPieChart({
       
        lineName: lineName,
        StartDate:startDate,
        EndDate:endDate

    });
//    AnalysisInfotable.AddRow({Label:"ioEntries",Value:queryresults.rows[0].iOEntries});
//    AnalysisInfotable.AddRow({Label:"nioEntries",Value:queryresults.rows[0].niOEntries});
        AnalysisInfotable.AddRow({Label:"ioEntries",Value:50});
    AnalysisInfotable.AddRow({Label:"nioEntries",Value:60});
   
    logger.info(queryresults.rows[0].iOEntries);
    
} catch (e) {

    logger.error("There is an error in service getPieChartDataOnMashup DataBase service.SQLQuery_GetEntriesForPieChart " + e);

}
 let result = AnalysisInfotable;

 

Do you guys know that how can i make infotable to show more then 500 rows. I am getting data from SQL query and its more then 500 but as the infotable only shows 500 rows. any idea how can i fetch more then 500? For datatable i know how to make it work with maxItems but i am not sure about infotable.

View solution in original post

4 REPLIES 4

i am unable to read in logger ioEntries like ab.rows[0].ioEntries
looks like spelling mistake, but you in logs you have iOEntries (low I, O in capital, E in capital, rest of text in low), but then you write ioEntries (O in low, not in capital).
Of course, if it's only mistake in your post, then do not care about my answer, but if it is also in your code - then I hope I helped you. Sometimes it's most difficult to notice such a small mistypes

Hi @Jamal8548 , 

 

Try to log the complete infotable in the logger like below code

logger.info(ab.ToJSON());

Else you need to log only 1 column values means please find code.

logger.info("Log Message Of First ioEntry Value: " + ab.rows[0].ioEntries);

 

Thanks & Regards,

Arun C

Hi @ZbigniewK  and @Arun_C 

 

Thanks both of you for your insights. Its actually spelling mistake and sometime thingworx needs to be refresh the service inorder to see effects but yeah its working now. Below is my code also. May be it will be useful for other people.

 

const SERVICENAME = "getPieChartDataOnMashup";
logger.info(me.name + " :: " + SERVICENAME + " :: Start Service");

let projectName = me.name.match(/^[^.]*/)[0];

let AnalysisInfotable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
    infoTableName: "InfoTable",
    dataShapeName: "V2.Analysis.DS"
});

let queryresults;
try {
     queryresults = Things["V2.MYSQLDatabaseController"].SQLQuery_GetEntriesForPieChart({
       
        lineName: lineName,
        StartDate:startDate,
        EndDate:endDate

    });
//    AnalysisInfotable.AddRow({Label:"ioEntries",Value:queryresults.rows[0].iOEntries});
//    AnalysisInfotable.AddRow({Label:"nioEntries",Value:queryresults.rows[0].niOEntries});
        AnalysisInfotable.AddRow({Label:"ioEntries",Value:50});
    AnalysisInfotable.AddRow({Label:"nioEntries",Value:60});
   
    logger.info(queryresults.rows[0].iOEntries);
    
} catch (e) {

    logger.error("There is an error in service getPieChartDataOnMashup DataBase service.SQLQuery_GetEntriesForPieChart " + e);

}
 let result = AnalysisInfotable;

 

Do you guys know that how can i make infotable to show more then 500 rows. I am getting data from SQL query and its more then 500 but as the infotable only shows 500 rows. any idea how can i fetch more then 500? For datatable i know how to make it work with maxItems but i am not sure about infotable.

Hi @Jamal8548 ,

 

Kindly increase the Max rows from Database Thing - SQL query service. If you need to all rows make it with -1. It will works.

Kindly find the attached link - https://www.ptc.com/en/support/article/CS332284

Arun_C_0-1713430013786.png

 

Thanks & Regards,

Arun C

 

Top Tags