Forum Discussion

MarkShnier__You's avatar
MarkShnier__You
Icon for Qrew Legend rankQrew Legend
4 years ago

How to trim a list to X number of records.

I have a hypothetical situation that I need to program.  I will be creating say 80 child record for "Student Sessions" knowing that some of them will fall on blackout dates. (Holidays, or Staff or Student unavailability dates).  Each record will be for a different date and then would be listed in date sequence on an embedded table on a the Student Record record form.   I know that I really only need exactly 60 records created but I will initially create 80 knowing that some will need to be deleted due to blackout dates.  I can delete the records automatically (or perhaps I will be able to not create them if they fall on blackout dates).

So suppose I now have 75 Student session records which survived the blackout dates. 

Any bright ideas on how to auto delete (even pushing a button to run a pipeline) to delete out the extra 15 Student sessions with the highest dates? 


------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
mark.shnier@gmail.com
------------------------------

2 Replies

  • Hi Mark,

    I'm sure you've thought of this and discounted for some reason...

    If I was doing this I would:

    1) Use Count Summary fields to determine the number of dates which need to be deleted, and pass this back to the child via a lookup.

    I assume the max possible is 80-60=20?

    2) Use Max Summary fields (you'd need 20 of these to cover the max you'd ever need to delete) to identify the child record IDs with the highest dates excluding your blackout dates with each summary excluding the value of the preceding one.

    3) Pass these IDs back down to the child records in 20 separate lookups.

    4) Create a formula checkbox field called something like 'Record to be deleted?' to identify where the record ID of that specific child equals any of the up to 20 record IDs you've pulled from the parent via the lookup and identified as needing to be deleted. You'd use the value from Step 1) in your formula, to determine how many of the 20 fields to check.

    5) Use a timed automation (or pipeline) to delete any child records with that flag checked.

    I've done something similar to this (without step 5) where I needed to identify the latest 9 'active' records (with no limit on the potential total number of child records) in a child table, allowing for uses to re-order and manually exclude / re-include records, and it works fine.

    In fact I'm pretty sure it was one of your posts, Mark, that inspired this approach!

    Lol.

    Hope you can get your head around this now, and that for a change I can actually help you with something!

    David



    ------------------------------
    dmlaycock2000 dmlaycock2000
    ------------------------------
    • MarkShnier__You's avatar
      MarkShnier__You
      Icon for Qrew Legend rankQrew Legend
      OK, interesting.  I only thought to count forward and was thinking it would be crazy to do 80 summary fields.   but I can count backwards, In fact I could do say the 10 highest dates and have a button to delete up to say 10 "extras" at time extra in one click.   Or maybe a Pipeline.

      Thx, I have an approach now.

      ------------------------------
      Mark Shnier (YQC)
      Quick Base Solution Provider
      Your Quick Base Coach
      http://QuickBaseCoach.com
      mark.shnier@gmail.com
      ------------------------------