Jump to content
Sign in to follow this  
chob1234

Returning multiple values in an ordered array

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?

Share this post


Link to post
Share on other sites

What errors are you getting?  If Color is supposed to be a value and not a variable, you need to quote it.

Share this post


Link to post
Share on other sites

Sorry not errors, it is returning all of the information for input partID, I thought that the sort function would return just the Color of that partID, which it is not.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...