Skip to main content
10-Marble
June 29, 2023
Question

How To Prevent Sort Ascending Order Of Dynamic Column Name in Services Output

  • June 29, 2023
  • 2 replies
  • 2672 views

Hi Team,

I am facing this issue mentioned below:

I want to prevent sort ascending order .Please help on this and provide solution

Thingworx Version-V8.5.6

MM_10159448_0-1688038237886.png

 

 

2 replies

22-Sapphire I
June 29, 2023

If you are generating this in a service, then you can apply your desired sort in the service before setting it to result.

Hope that helps.

10-Marble
June 30, 2023

Hi PaiChung,

Thank you for your reply

Applying desired sort means,not understood clearly, can u please explain or share some code if you have as an examples?

Currently, I am not applying any sort in service, You can see in screenshot, Whatever , I am sending as an input sequence, same I want in infotable service output. without sort ascending order

12-Amethyst
June 30, 2023

Hello,

 

Can you provide some code snippets from your service to help us understand how you are building the infotable.  My assumption from your screen shot and using "Dynamic Columns"  is that you are creating the data shape for the info table on the fly either entirely or adding columns to an existing data shape using AddField or fieldDefinitions.

 

In either case column order is not guaranteed to be in add order by default.  If you want to guarantee columns are in a specific order you must specify the ordinal property when adding the column.  Please see the following support cases for examples: CS313173 CS388066 

 

Thanks,

Travis

10-Marble
July 6, 2023

Hi Team,

Thank you for providing to set ordinal property information.

Now, Service giving desired output when executing service manually from composer but when checked in runtime 'Developer Tools' not getting desired output

Pls check both screenshot 

Let me know any solution on it

 

Ordinal_Runtime_Developer Tools.PNGOrdinal_Manual Exec.PNG

16-Pearl
July 7, 2023

A json object does not account property order. (https://stackoverflow.com/a/16870531)

The "ordinal" property is a twx-specific metadata which twx toolings will consider. The "wanted" order you can see in developer tools response in "datashape" (your screenshot shows the "rows" of the response) 

nmutter_0-1688767546697.png

 

May I ask the use case why you rely on the order of the properties?