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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Can't add row for infotable in runtime

aelgov
1-Newbie

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 4
jkaczynski
4-Participant
(To:aelgov)

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.

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

supandey
19-Tanzanite
(To:aelgov)

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

newEntry.DateTime = log.DateTime;

newEntry.Reason  = log.Reason;

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

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

Announcements


Top Tags