Select multiple records in script

Using the scripting block, is it possible to prompt the user to select multiple records?

My script is going to start with asking the user to select a record. Then (ideally), they will be prompted to choose which of the linked records to move forward with (checking off all that apply). I haven’t found a way to do this so far using the methods described in the scripting block documentation.

I think the only reasonable approach (given the limitations of the Script Block SDK) is to:

  • Create an array list of the linked candidates the user needs to choose from;
  • Enumerate that list in a while loop asking the user to confirm (or reject) each candidate while updating the array to flag the confirmations;
  • When the while loop ends, you will have an array of records to process;
  • Finish the job…

Indeed, I agree. I’m already heading down this path as I was waiting for a community answer on my ideal scenario. Thanks very much, Bill!!

Scripting block does not have a built in way of selecting which items in a list to act upon. This limitation is a result of scripting block essentially presenting users with a command line interface.

So, we must get creative in figuring out how to get that information. Since all of the methods have their failings, a lot depends on how many items there are in the list, and whether the programmer can guess the likely choices.

  • Present each item in order with a yes/no button for each. (Bill’s suggestion) But this can be cumbersome if there are lots of records.

  • Have the user setup a view that includes only the desired records, and then ask the user for the view. But creating a view has a lot of overhead.

  • Group the list items into logical groups, and present a menu of buttons, with one button per group. For example, a button for all items, a button for “new” items, a button for the “first five”, etc. But this requires some guesswork on the part of the programmer for to set the groups, and will likely need a backup.

  • Present a menu of items and have the user enter the selections in a text string. Parse the text string to figure out which ones to use. This method actually has a huge number of variations. For example, the user could enter item numbers similar to how you enter page numbers in a print dialog box. Or you could have the use copy/paste the items into a comma separated list. But parsing the text string can be a pain.

Or, here’s another option. Use buttons. One button per list item, plus buttons for select all, select none, and done. Clicking a button toggles the selection for that item, and the color of the button shows if the item is currently selected or not.

Here’s an example. Suppose a user needed to pick from colors of the rainbow, but you didn’t know which colors the user wanted or how many.

Pick the first color:
[red][orange][yellow][green][blue][indigo][violet][select all]

The user clicks [red].

Currently selected colors: red
Pick another color or click done:
[red(in a variant color)][orange][yellow][green][blue][indigo][violet][select all][unselect all][done]

The user clicks [green].

Currently selected colors: red, green
Pick another color or click done:
[red (in a variant color)][orange][yellow][green(in a variant color)][blue][indigo][violet][select all][unselect all][done]

The user clicks [blue].

Currently selected colors: red, green, blue
Pick another color or click done:
[red (in a variant color)][orange][yellow][green(in a variant color)][blue(in a variant color][indigo][violet][select all][unselect all][done]

The user clicks [done].

You keep track of what is selected in the array you pass to the input.buttonsAsync function, and you evaluate the button input with a switch statement. Finally, you throw a while loop around the whole thing.

The overall number of clicks is basically the same as the number of clicks when selecting check boxes, but the presentation is different. If you want to get really tricky about it, clear the screen with each loop, so the user doesn’t see the buttons as a new set of buttons each time.

2 Likes