Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › Add up or down?
- This topic has 7 replies, 4 voices, and was last updated 1 month, 3 weeks ago by Daniel Leu.
-
AuthorPosts
-
October 26, 2024 at 1:45 PM #51225
Glen ForisterParticipantIn Multi-column List View, on my laptop MacBook M1 Pro, I am editing a long list of items that are in order by Group (Class), then 3 sort fields.
I am going through this list and adding information to each record and adding records as I go which are in the order I encounter them.
When I add a record that is mostly like the last one I worked on, I use the “Command D” to duplicate the last record I worked on.
The new record inserted is sometimes positioned after that record I was on which keeps them in order. Sometimes it is positioned before the record I was working on and therefore out of order after I add the new information.
Is there a way to have this “Command D” consistent and add the duplicated record after the record it was duplicated from?
October 27, 2024 at 8:55 AM #51227
BrendanKeymasterHi Glen,
Unfortunately when two records have the exact same values, there’s no determination of which record should come first because the sorting is non-deterministic at that point. So there’s nothing I can think of at the moment that I can do about that.
Sorry.
Brendan
October 27, 2024 at 8:55 AM #51228
BrendanKeymasterThe only thing you could do is add a Date Created field type to your form and sort by that. Then Tap Forms would have something unique to sort by.
October 27, 2024 at 9:16 AM #51229
Glen ForisterParticipantThat sounds ok, except I have to sacrafice my 3rd sort. I suppose there isn’t another sort field?
I’m already using Group by Records and then 3 sorts.
October 28, 2024 at 7:17 AM #51232
JScottAParticipantDoes this help you? I’ve not tested it but maybe it will spur your creativity for a real solution:
To achieve the desired effect of consistently placing duplicated records immediately after the original in Tap Forms, a JavaScript-based scripted function could provide a workaround. Here’s a general approach, leveraging the Tap Forms API capabilities found in the documentation:
1.Retrieve the Current Record’s Position: Identify the position of the original record within the sorted list.
2.Duplicate the Record: Use the record.duplicate() function to create a copy of the current record .
3.Insert at Correct Position: Based on the original record’s position in the form’s sorted list, reposition the duplicate if needed. This could be done by iterating over records to ensure the duplicate’s position is adjusted relative to the original.
Here’s a basic script outline:
// Retrieve the current record
var records = form.getRecords();
var currentRecord = form.getSelectedRecord(); // assuming this is the record to duplicate
var index = records.indexOf(currentRecord);
// Duplicate the record
var duplicatedRecord = currentRecord.duplicate();
// Reposition the record if needed by sorting again or programmatically moving
// Example: You might delete and re-add in sorted order if Tap Forms sorting is strict
form.saveAllChanges();
This script, while a creative workaround, may have limitations if Tap Forms enforces strict sorting on save, potentially reordering records automatically. Testing would determine if the manual duplication places the record in the intended position consistently.
October 28, 2024 at 8:57 AM #51233
Glen ForisterParticipantThanks for the thought. That is interesting.
If I could easily make a duplicate of my TF file and test it, I would try that. But, I have 79 Forms in my document. I’ve been burned by tests before.
It sounds pretty straight forward and if I was just starting out I would try the script, but I have over 200 records now to sort out if things go wrong.
October 28, 2024 at 11:17 AM #51234
BrendanKeymasterGlen, if you want to try things out on your document, close it, then use the Duplicate Document command to have Tap Forms make an exact copy of your document. Give it a different name, e.g.
My Document - Test
and play around with that. DON’T use the Finder to make a duplicate of a document because it won’t assign a unique Document ID to the document.October 28, 2024 at 4:47 PM #51235
Daniel LeuParticipantAdditionally, I would add some additional forms and records that stand out, maybe even change the color of records. If you use the custom layout, use a different/ugly color. Just to make it more difficult to use the wrong document!
Side note:
form.getSelectedRecord()
is not a TapForms API call, but you can userecord
instead. -
AuthorPosts
You must be logged in to reply to this topic.