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

OUTPUT ERROR: ReferenceError: "myinfotable" is not defined.

SOLVED
Alexandrite

OUTPUT ERROR: ReferenceError: "myinfotable" is not defined.

Hi, Can c8d7428d-7afa-44f1-b0c7-2a950b5493c6.pngsomeone help me to fix this problem ASAP? thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: OUTPUT ERROR: ReferenceError: "myinfotable" is not defined.

In your case the simplest way to go is this (don't do it on the large data tables):

var result = Resources["InfoTableFunctions"].Aggregate({
	t: me.QueryDataTableEntries({ maxItems: 1000000 }),
	columns: 'KPI_Value',
	aggregates: 'SUM',
	groupByColumns: 'No'
});

/ Constantine

View solution in original post

21 REPLIES 21

Re: OUTPUT ERROR: ReferenceError: "myinfotable" is not defined.

Hi,

Where is this infotable declared? Should it be a service parameter, or is it a thing property? In case it's a property from the same thing as the service, it should be referenced as me.myinfotable

Re: OUTPUT ERROR: ReferenceError: "myinfotable" is not defined.

I put infotable under datashape and after I change from myinfotable to me.myinfotable, it pop this new error: 

Re: OUTPUT ERROR: ReferenceError: "myinfotable" is not defined.

Hello,

 

When you type "me.myinfotable", it means that there's a property called "myinfotable" on the thing where you define this service, in your case on "GF Datatable PV UHT 1000 ml". Do you have this property defined there? If yes, then where does the data come from, how do you initialize it?

 

If no and you want to aggregate some data from this data table, then you should probably do something along those lines (check Help for details about those services):

var myinfotable = me.QueryDataTableEntries(...);
var result = Resources["InfoTableFunctions"].Aggregate({
t: myinfotable,
...
});

Regards,
Constantine

Re: OUTPUT ERROR: ReferenceError: "myinfotable" is not defined.

ok. thank you. if I say I want to use datatable's data to do an aggregation how to do that way?

Re: OUTPUT ERROR: ReferenceError: "myinfotable" is not defined.

Like that:

var values = me.CreateValues();

values.property1 = value1;
values.property2 = value2;
values.property3 = value3;

var entries = me.QueryDataTableEntries({
	maxItems: ...,
	values: values,
	query: ...
});

var result = Resources["InfoTableFunctions"].Aggregate({
	t: entries,
	columns: ...,
	aggregates: ...,
	groupByColumns: ...
});

You will find more about service parameters that I replaced with ... in ThingWorx Help.

 

/ Constantine

Re: OUTPUT ERROR: ReferenceError: "myinfotable" is not defined.

In your case the simplest way to go is this (don't do it on the large data tables):

var result = Resources["InfoTableFunctions"].Aggregate({
	t: me.QueryDataTableEntries({ maxItems: 1000000 }),
	columns: 'KPI_Value',
	aggregates: 'SUM',
	groupByColumns: 'No'
});

/ Constantine

View solution in original post

Re: OUTPUT ERROR: ReferenceError: "myinfotable" is not defined.

And then if I want to sum data monthly, how to do that? I try getMonth() function alr, but it seems like summarize all data so far I key in. 

var result = Resources["InfoTableFunctions"].Aggregate({
	t: me.QueryDataTableEntries({ maxItems: 1000000 }),
	columns: 'KPI_Value',
	aggregates: 'SUM',
	groupByColumns: 'Date.getDate()'
});

 11111.png

Re: OUTPUT ERROR: ReferenceError: "myinfotable" is not defined.

I would do it like this:

  1. Add a field "month" to your DataShape for the data table;
  2. Fill this field with the correct month when you insert data into the data table;
  3. Use this field in groupByColumns, like that:
var result = Resources["InfoTableFunctions"].Aggregate({
	t: me.QueryDataTableEntries({ maxItems: 1000000 }),
	columns: 'KPI_Value',
	aggregates: 'SUM',
	groupByColumns: 'month'
});

/ Constantine

Re: OUTPUT ERROR: ReferenceError: "myinfotable" is not defined.

thank you for your reply. but this method I try before, i prefer automatically sum weekly value and then get the monthly value as customer requirement.