This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
Is there a way to sort fields based on name while preserving the fields' data type?
I'm creating a macro at the end of which certain fields are sorted into a specific order--note, the fields fed into the macro are dynamic. The macro is set up such that fields are renamed with a number prefix for ordering and then sorted according to their name. After sorting, the prefix is removed.
I have not been able to sort based on field names with the select tool unless I'm in the macro and sort them manually--i.e., go to the select tool, chose options > sort > sort on field name > ascending. I've tried using a check-box to update the 'order changed' property within the select tool, but it doesn't seem this does anything.
Using the Crew macro 'Field Sort' is not an option, at least not without some modification, as running data through this converts all fields' data type to string.
The first thing that comes to mind is build a second macro to act as a shell for the original macro. This macro would determine the field types and order or the fields and update the XML of the select tool of your macro.
If I have some time (and someone else doesn't beat me to it), I'll build an example.
Some of us in the community have created a small group of custom, unofficial, Python tools. One of these tools is a field sorter which can do what you want. One of the options in the tool is to sort fields alphabetically. The tool, by design, always retains the original data types:
If a custom tool is an option for you, you can download it from here. Installation should be easy: just double-click on the installer and it will get installed into the Preparation tab. Everything is open source; you can view the code and the other tools from our main Github page.
I love the Python sort macro. However, I am having some trouble with it:
1) where is this macro installed? Everything works just fine with it, but I would like to run the macro on our server, and to be able to do it, I would like to have the macro in a shared drive and refer to that location.
Hey @joona_rauhamaki, if you install it as a non-admin, the default installation directory should be something like:
If you install it as an admin for all users the custom tool should go to:
So if you want to install it on the server for all users, this is where I would usually put it. Because it is not a macro, I am not sure you can install it to a custom shared location (like the macro library from the user settings dialog).