Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Why does a loop not loop?

Featured Replies

Good Afternoon,

I’ve written a script to create a virtual list of titles from two tables. The script is executed from a table B record. It first searches for the records in table B where the author is the same as the author on the table B record from which it is executed, and then for table A records with that same author.  Everything works fine as long as the table B record has only one author in the author field. When there is more than one, the script fails to loop through the table B author field. It looks like it is taking only the first author into account. The table B author field is based on a dropdown list of names all separated by a carriage return. I’m pulling my hair trying to understand why it’s not working.

Any help would be greatly appreciated. Thanks.

 

Script (part 1).PNG

Script (part 2).PNG

It's hard for me to follow your script but basically when pulling records like this, you probably need a loop in a loop.

Also, when doing a virtual list, you usually have to append the results in a variable (over and over when looping), local is faster, then move that entire value to a global variable if need be.

Virtual list requires that you pre-populate the table with more records than you could ever need, then performing a find on a field guaranteed to have a record, unless you're building your VL with repeating fields.

Probably the only way to solve this is with a sample file.

  • Author

Thanks Steve,

As far as the virtual list is concerned, the script works just fine. It creates and populates the virtual list with all the found records. So that is not the issue I'm concerned with.

The problem I'm having is that the script does not find all the records it should find because, when there is more than one name in the authors field of table B (where the script is executed), the script searches table B records and then table A records only with the first name in the authors field. It should continue the search with the 2nd, 3rd, 4th name, and so on. So lines 8 to 18, and then 28 to 34 of the script need some adjustments, maybe as you say another loop. This is where I need some guidance.

Note that line 37 should read Set content of virtual list from books (not from acquisitions).

Thanks.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.