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

Can't add row for infotable in runtime

Hi,

I want to create new infotable from datashape, then add rows to it.

I get an error:

JavaException: com.thingworx.common.exceptions.InvalidRequestException: Invalid Reference to Object In Script

This is the code I use:

var params = {

  infoTableName : "InfoTable",

  dataShapeName : "MyInfoTableDataShape"

};

var myInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

for(var i = 0; i < Logs.length; i++){

var newEntry = new Object();

newEntry.DateTime = logDateTime;

newEntry.Reason  = log.Reason;

myInfoTable.AddRow(newEntry);

}

var result = myInfoTable;

When I add rows to an infotable property and add - var result = myInfotableProperty it works like a charm.

4 replies

1-Visitor
February 27, 2017

Hi Assaf Elgov​,

You're referring a different variables in your script, such as: Logs, logDateTime, log.Reason. Are you sure each is a valid variable / parameter?

What version of Thingworx do you use? What parameters of what base type you pass to this service?

Regards,

J.

Translate
aelgov1-VisitorAuthor
1-Visitor
February 27, 2017

It is just part of the code not the whole code.

I'm 100 percent sure it is valid, I logged them.

TWX version: 6.6.9

all strings besides 1 which is number

Translate
5-Regular Member
February 27, 2017

Assaf, you missing "." for adding DateTime from Logs, shouldn't it be

newEntry.DateTime = log.DateTime;

newEntry.Reason  = log.Reason;

Translate
aelgov1-VisitorAuthor
1-Visitor
February 27, 2017

It is just part of the code not the whole code.

Because I use alot log.DateTime I inserted it into var called: logDateTime

Translate