Skip to main content
10-Marble
December 3, 2024
Solved

Issue with Infotable Property Logging and History Updates

  • December 3, 2024
  • 3 replies
  • 1980 views

I have an Infotable property that is enabled for logging and is persistent.

This Infotable contains three columns: Number, StartDate, and EndDate. The table is updated every 24 hours.

The update logic is as follows:

  1. I first assign the Infotable to a variable in the script.
  2. I modify the dates as needed.
  3. I update the property using me.property.

While this updates the Infotable with the new values (updated dates), when I query it using QueryNamedPropertyHistory or QueryInfoTablePropertyHistory, I only see one log entry for the property instead of a complete history.

Could you help me understand why the logs aren’t being recorded as expected?

Thingworx version -> 9.3.8

Best answer by Rocko

You probably have to set the "" in the property configuration to "On" for property type Infotable.

3 replies

18-Opal
December 3, 2024

Those variables are just pointers to objects in memory, so if you don't create a new object, ThingWorx won't know that you modified the content and so it won't overwrite the value in the database. Try to create a new object by cloning your property first:

let it = Resources["InfoTableFunctions"].Clone({ t1: me.property });

/ Constantine

10-Marble
December 3, 2024

Thank you! However, in my case, I am creating a new Infotable and adding rows to it. Here's my code.

shift = Things[Thingname].StandardShiftTime;
for(l=0;l<shift.getRowCount();l++){
sd = shift[l].StartDate;
ed = shift[l].EndDate;
var SDate = new Date(sd); // Replace this with your desired date
SDate.setDate(SDate.getDate() + 1);
var EDate = new Date(ed);
EDate.setDate(EDate.getDate() + 1);
// Shift.DS entry object
let newEntry = {
Shift: shift[l].Shift, // INTEGER
StartDate: SDate, // DATETIME
EndDate: EDate // DATETIME
};
outputtable.AddRow(newEntry);
}
Things[Thingname].StandardShiftTime = outputtable;

18-Opal
December 3, 2024

Well, one of the reasons why it doesn't log changes might be because the scheduler fails, for example the user who runs it doesn't have enough permissions to execute this code. Are you sure it executes correctly every 24h, do you log it somewhere? Are changes saved in the property and its history when you run this code yourself in Composer?

 

Also, instead of "Things[Thingname].StandardShiftTime = outputtable" you can use SetPropertyValues explicitly:

 

let props = Resources["InfoTableFunctions"].CreateInfoTable();
props.AddField({ name: 'StandardShiftTime', baseType: 'INFOTABLE' });
props.AddRow({ StandardShiftTime: outputtable });
Things[Thingname].SetPropertyValues({ values: props });

 

See details here: https://www.ptc.com/en/support/article/CS221424

 

/ Constantine

Rocko
Rocko19-TanzaniteAnswer
19-Tanzanite
December 3, 2024

You probably have to set the "" in the property configuration to "On" for property type Infotable.

10-Marble
December 5, 2024

Thank you!
This helped me log the InfoTable, and now I can see it using both QueryPropertyHistory and QueryInfoTableHistory.

14-Alexandrite
December 3, 2024

SD
I encountered a similar issue, but as @Rocko  suggested, changing the data change type to "On" allowed me to see the log history for the infotable property.