Skip to main content
10-Marble
Jun 29, 2023 11:24 AM UTC
Question

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

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

 

 

8 replies

22-Sapphire I
Jun 29, 2023 4:54 PM UTC

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.

Translate
10-Marble
Jun 30, 2023 6:53 AM UTC

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

Translate
12-Amethyst
Jun 30, 2023 2:32 PM UTC

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

Translate
10-Marble
Jul 6, 2023 3:52 PM UTC

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

Translate
17-Peridot
Jul 7, 2023 10:09 PM UTC

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?

Translate