"Add" button for many-to-many related record
Hi, I know I can add a related record to a portal just by filling out the blank row, but for usability reasons I'd rather do it with a button that would pop up a friendly form.
I have a first cut of it now, a button that launches this script, below. Can anyone check my work and suggest any improvements or tell me if there's any gotchas?
New Window [Name: "New Widget"; Height: 500; Width: 400; Style: Floating Document] Set Variable [$customer_id; Value:Customer::id] Go to Layout ["Widget" (Widget)] New Record/Request Set Variable [$widget_id; Value:Get ( RecordID )] Go to Layout ["CustomerWidget" (CustomerWidget)] New Record/Request Set Field [CustomerWidget::customer_id; $customer_id] Set Field [CustomerWidget::widget_id; $widget_id] Commit Records/Requests  Go to Related Record [From table: "Widget"; Using layout: "Widget" (Widget)] View As [View as Form]
Details: From a Customer, this creates a new related Widget. "Customer" has a customer_id field; "Widget" has a widget_id field; and they are many-to-many related through a "CustomerWidget" table that has a customer_id field and a widget_id field. The tricky part is that I wasn't quite sure how to accomplish creating both the new Widget row, *and* the new CustomerWidget row in one process, so that's the workaround so far.