Jump to content
gillekes

Sorting search results

Recommended Posts

gillekes

Hi Everybody,

I have a portal on layout A from table A on which I can add a fields from table B.

To add the fieds  to layout A a script opens a new window and goes to the search layout with a list view of the records. I scripted a find funtion for easy finding of the record and aonther script adds the fields from the chosen record to the portal on layoutA. This works well and I'm happy with it.

What I would like to do is sort the records in the list view on the search layout BEFORE perfoming the find script. The sort result should give a list of the latest added records. This updates every time a field is added to layout A. The latest goes to the top the list.

I gues I could add a serial number field to table B and this field would get a new number everytime the field is added and then sort descending... But this is going give huge numbers...

Any ideas or sugestions?

 

Thanks,

 

Gilles

Share this post


Link to post
Share on other sites
Steve Martino

You should always have a serial number field (on creation) for relationships.  

If you don't sort the records (unsort) the records will (should) be in creation order.  You could leave it like that (not recommended). Then you could use Replace Field Contents, with the serial number option in the new serial number field, to populate all existing records with serial numbers.

From there, you could just sort by serial number.

I wouldn't use this method with UUID serial numbers for obvious reasons.

Another option would be to use an on creation timestamp, but you won't be able to accurately populate existing records.

Share this post


Link to post
Share on other sites
gillekes

Hi Steve

I do have a serial number in all tables so they can relate to each other and they are only used for relations.

I don´t want to sort on criation date. I want to to sort the list on last added to a portal. The records allready exist.

If you look at the grab attached you see a list. The first row is Solvent Yellow 56. Next I would add Maltodextrina (row4) to the portal on the other layout (by pressing the plus sign on the corresponding row, which has a script that does that).

What I would like is that list would be sorted again and the maltodextrina would go to the first row and all the other rows would lower one.

Looking for a good practice on how to achieve this.

 

Thanks,

 

Gilles

 

grab.jpeg

Share this post


Link to post
Share on other sites
Steve Martino

I think if you create a creation timestamp from the table the portal is based on, and sort descending in your portal setup, it would work.

When you add a record to a portal you are 'creating' a record in that table, with it's accompanying timestamp.  So sorting descending on the timestamp should work.  

You may have to refresh the portal or refresh the entire layout with 'flush cached....' checked.

The field doesn't have to show in the portal.

 

If that doesn't work it may help if you show a screenshot of your relationship graph, a screen shot of the layout in layout mode, the script that produces the portal record, and/or a sample file

Share this post


Link to post
Share on other sites
gillekes

Good idea, I'll try!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×