Jump to content

Returning multiple values in an ordered array


chob1234
 Share

Recommended Posts

var params = {
	maxItems: 100000 /* NUMBER */
};

//// result: INFOTABLE
var itPartInfo = Things["Training.InfoTable.PartInfo"].GetDataTableEntries(params);

///*****************************************

//	ADD YOUR CODE BELOW
    
//*****************************************/

var query = {
  "filters": {
    "fieldName": "ID",
    "type": "EQ",
    "value": partID
  }
//partID is an input
};

var idQuery = {
	t: itPartInfo /* INFOTABLE */,
	query: query /* QUERY */
};

//// result: INFOTABLE
var result = Resources["InfoTableFunctions"].Query(idQuery);

So this code will return an item in an infotable(thingworx) which is basically an array of objects, it can also be thought of as a table where the array entries are rows and the object properties of each object in the array are the columns. So currently my output is displaying what I have correctly, I need to know how I could display say partID, Color, and MaterialType, my thinking was a I could use a sort function like 

var sort = new Object();
sort.name = Color;
sort.ascending = True;
itPartInfo.Sort(sort);

But I am getting errors. Any suggestions?

Link to comment
Share on other sites

It seems like a sort function would just change the order that the results appear.  If you want to limit what is returned you probably have to change the table specification to tell it to only return specific columns, but I'm not familiar with what you're using.  Hopefully it has documentation that you can use to check what your options are.

Link to comment
Share on other sites

Yeah I think you are right on that, I believe the only way as of now in the thingworx platform to remove undesired columns is the .removeField("field") function, which you would have to have a function for every single column which is very inconvenient. 

Edited by chob1234
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...