Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Use Case: You’ve published a model from Analytics Builder to Analytics Manager, and then used service CreateOrUpdateThingTemplateForModel on resource TW.AnalysisServices.ModelManagementServicesAPI. A thing created from the resulting template will have an infotable called “data” which needs to be populated in order to trigger an Analysis Event & Job.
For example you might have been following the online documentation for Analytics Manager > Working with Thing Predictor > Demo: Using Thing Predictor, link here.
This script makes it easy to create a line of test data into field "data" on your thing to trigger the analysis event & job. Also fields causalTechnique, goalName and importantFieldCount are set programmatically, these are needed for the analysis event & job.
Also this script might be useful as a general example of how to write to an infotable property on a thing.
The JavaScript code is shown here and also attached as a text file to this post:
me.causalTechnique = 'FULL_RANGE'
me.goalName = 'predict_Compressor_failure'
me.importantFieldCount = 3
// ThingPredictor.test_3f1a6a31-e388-4232-9e47-284572658a4a.InputParamsdataDataShape entry object
//var newEntry = new Object();
var params = {
infoTableName : "InfoTable",
dataShapeName : "ThingPredictor.test-integer_afebaef3-b2cf-4347-824c-a39c11ddbb4a.InputParamsdataDataShape"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(ThingPredictor.test_3f1a6a31-e388-4232-9e47-284572658a4a.InputParamsdataDataShape)
var myInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
// 2 - CREATE INFOTABLE ROW USING object
var newEntry = new Object();
newEntry._Pressure = 10.5; // NUMBER
newEntry._Temperature = 45.1; // NUMBER
newEntry._VibrationX = 81; // NUMBER
newEntry._VibrationY = 65; // NUMBER
//newEntry.key = 4; // STRING - isPrimaryKey = true
// 3 - ADD INFOTABLE ROW USING TO INFOTABLE
myInfoTable.AddRow(newEntry);
// 3 – PERSIST INFOTABLE TO THE THING PROPERTY ‘data’
me.data = myInfoTable;