You need to sign in to do that
Don't have an account?
Ordering of fields when pulling fieldnames dynamically
Hi,
I have a dynamic object edit page that takes an object's name and then displays all of the fields that it has dynamically. However, it seems like the order in which these fields are displayed is somewhat random (It is not alphabetically ordered like in the schema, and it is not ordered the same that it is displayed in the object itself).
Does anyone know where this ordering is coming from? I want to retain a dyamic edit page without manually having to re-order the fields for each object (Which destroys the utility of a dynamic object edit page anyways).
Thanks,
Vivo
If this a standard edit page, then please edit the page layout. If it is a custom page, then how are you fetching the fields? If using field set then please rearrange the order in the field set.
I'm actually pulling the fields by using:
So it is actually using neither field set or standard page. I'm just curious where the ordering from the map is coming from. It seems to be arbritrary when I look at it.
1. Create one wrapper class that will keep field API name and label.
2. Use a map which will have the label(keyset) to api name of the field.
3. Now iterate a list which contains the field labels in the order you want to display in page.
4. Then create the object of wrapper class and put into the list of the wrapper class which you are going to use in the page.
Hope you got it. Let me know. If not I shall send you a sample.
Yeah this was the solution that I reached in the end too. Seems like the best way to proceed. I just wanted to ask on here if anyone knew where that order was coming from originally because it seems like there would be no reason for it to be random.
Thanks though!
-Vivo
I've finally went back to this problem and realized that the system was pulling in the fields at reverse creation order! So all I had to do was reorder the map in reverse and then get the order that I want (As long as I made the fields in the correct order.)