Sage 100: VBScript Popup Selection in Customizer
VBScript in Sage 100 Customizer has no clickable grid for a popup selection. Here is the proven numbered-list InputBox pattern that returns the picked row to SO line UDFs, and the Advanced/Premium alternative.
You want a button on the Sales Order lines that looks up rows for the current item — part revisions, customer-specific part numbers, alternate sources — shows them to the user, and writes the row they pick back into UDFs on the line. The query is the easy part. The wall everyone hits is the popup itself: VBScript in Customizer has no grid control, no list box, and no way to render query results as a clickable table.
The proven workaround is to stop trying to make the list clickable. Number the rows, show the numbered list inside an InputBox, let the user type the number, and use that number as an index into the data you already loaded. It looks plain and it works — the implementation shared in the Community Hub thread replaced a slower VAR-built version and saved the poster's sales staff roughly 25 seconds per sales order line.
The fix
This pattern is confirmed on Sage 100 Standard (the MAS 90 architecture the thread was written on). Read the Advanced/Premium section before using it on those editions — where the script runs changes everything.
- Add the button. In Customizer, add a button to the Sales Order Lines panel and set it to run a VBScript. Make sure the script receives the current line's item code and the UDFs it must fill (in the thread's example: customer part number, customer revision, and master revision UDFs on SO_SalesOrderDetail) as panel variables, along with the standard MAS_SCR_* context variables.
- Run the lookup. From the script, open an ADODB connection to your SQL database and execute the query filtered on the current line's item code. Order the results so the row the user most likely wants sorts first — the example orders by engineering-change number descending.
- Load the rows into arrays. Walk the recordset once and store each column in a parallel array (one array per value you will display or return), counting as you go. Cap the list — the working example caps at 10 rows. If your lookup can return more than about ten rows, tighten the filter or the sort instead of building a longer prompt; nobody picks accurately from a 40-row InputBox.
- Build the prompt as a numbered list. Join the rows into one text string: a header line, then one line per row in the form
0) Rev | Cust P/N | Cust Rev | Customer, using Chr(10) between lines. Keep the columns few and short — Windows message text uses a proportional font, so tab-aligned columns will not line up no matter how carefully you pad them. - Ask with InputBox. Display the string with the VBScript
InputBoxfunction, with a clear title and the most likely row as the default value. The user types a row number and clicks OK. - Write the selection back. Use the returned number as the index into your arrays and assign that row's values to the SO line UDF panel variables. Assigning the panel variables is what populates the fields on the line the user is standing on.
- Clean up. Close the recordset and the connection and release the objects, including on the path where the user cancels — a cancelled prompt should write nothing and leave no open connection behind.
One caution on copying code: the contributor who shared the working script stated plainly that it had been cleansed before posting and that variable names might not match up throughout. Treat any code you find for this pattern as a schematic — re-type it against your own field and UDF names and test it on a copy company, rather than pasting and debugging someone else's sanitized example.
Options and approaches
Numbered InputBox (choose from many rows)
The pattern above. It is the only native-VBScript approach in the thread that handles a real list, because the "selection" is just an integer the user types. Best when the list is short, the rows can be identified from two or three short values, and the script runs where the user can see the popup (Standard, or a client-side button script — see below).
Session MessageBox with custom buttons (choose from a few options)
When the choice is genuinely small — yes/no, or up to about three labelled options — use the Sage session UI method instead of VBScript's MsgBox:
- Call
oSession.AsObject(oSession.UI).MessageBoxwith your message and custom button text, and branch on which button the user clicked. - This is the Sage-supported popup: later Hub threads are explicit that it is the preferred approach precisely because it works on the client/server editions where plain VBScript MsgBox does not.
- Its limits are hard ones: it returns a button choice only. It cannot collect typed text, and it cannot present a list — a handful of options is the practical ceiling before the buttons run out of screen width.
Client-side button script + UDF hand-off (Advanced / Premium)
On Advanced and Premium, a table-event script runs on the server, so a VBScript popup in one is shown on the server — or never shown at all. The documented architecture for user input on those editions splits the job in two:
- A button script set to Execute on Client shows the InputBox and captures what the user enters. A client-side script cannot work with business objects directly.
- In the button's Link Settings, select the variables to be passed and assign the captured value to a field variable (the documented example assigns the entered quantity to a UDF variable, which performs the SetValue into that UDF).
- A separate server-side Post-Validate script on that UDF does the real work — validation, lookups, printing, writes to other fields — where business objects are available.
A worked example from the Hub: prompting for a number of labels in Item Maintenance with a client-side InputBox, parking the quantity in a UDF, and letting the UDF's Post-Validate script print the labels. The same shape fits a selection: capture the picked row number (or key) on the client, park it in a UDF, and resolve it against your data in the server-side script.
What doesn't work
- Waiting for a grid control. There is no clickable grid or list control available to a Customizer VBScript, in any edition. Every working solution reduces the pick to a typed number or a button click.
- VBScript MsgBox/InputBox in a server-side script on Advanced/Premium. The popup renders on the server, invisible to the user — and InputBox in a server-side script cannot be seen by the user (an OLE error 70, Permission denied, is sometimes reported for this pattern in other discussions, but that specific error was not established in the source thread for this page — treat it as unconfirmed). If your script "runs but nothing appears," execution location is the first thing to check, not the code.
- Tab-aligned pseudo-tables in the prompt. Proportional fonts defeat tab alignment. If a row cannot be identified from a few short pipe-separated values, the InputBox list is the wrong tool for that lookup.
- Unbounded result sets. The pattern survives on its row cap. Returning every match into the prompt makes selection slower and more error-prone than the manual lookup the button was meant to replace.
Affected versions
- Confirmed in the thread: MAS 90 v4.3.10 (Sage 100 Standard architecture), button script on Sales Order Entry lines.
- The pattern still applies on current Sage 100 Standard, and on Advanced/Premium only in the client-side-button form described above.
- The limitation is architectural, not version-specific: server-side scripts on Advanced/Premium cannot present VBScript popups to the user, on any release.
Prevention / best practice
- Decide where the script executes before you write a line of it. Popup code and business-object code belong in different scripts on Advanced/Premium — design the UDF hand-off up front instead of discovering the split mid-project.
- Always cap and sort lookup results, and default the InputBox to the most likely row; most picks should be a confirmation, not a search.
- Validate the typed number before indexing your arrays (blank, non-numeric, and out-of-range input are all possible from a free-typed box), and make Cancel a clean no-op.
- Test the button with a user who did not write it. A numbered list that is obvious to its author can be ambiguous to the order-entry staff who use it two hundred times a day.
Related help
- User Defined Script Events
- Customizer Deep Dive for MAS 90 and 200
- Scripting Doc / Customizer Documentation Location
- Script for Customer Pricing
- Create a SQL Specific Pass-Through Query
Still stuck? Send us a screenshot of the error, we will diagnose it for free.
Digit Masters has supported Sage 100 and Sage 300 since 1997. Send the screenshot through our contact page or to contact@digitmasters.com, or call (800) 965-4262.