Scripting Update: Widgets

Thursday, June 22, 2017

One of the smaller, geekier features in the upcoming xTuple ERP 4.11.0 final release is the ability to write scripts on (some!) xTuple ERP desktop client *widgets*. We've long had the ability to write scripts to modify the behavior of existing windows and even write new ones, but now you'll be able to change the behavior of individual widgets.

Here's the deal with widgets

  • Not all widgets can be scripted, just those that inherit from the new `ScriptableWidget` class
  • The things you can do to a widget are limited by the basic capabilities of that widget

Why did we bother?

One feature requested by several customers is the ability to validate addresses. We prototyped this by writing a script to read information from our AddressCluster (that set of fields you see all over our desktop client application), send that info to the US Postal Service's address validation service, and appropriately update the data on screen with the result. That script then had to be copied several times and applied to different windows throughout the application. Wouldn't it easier to just apply that script to the AddressCluster itself? Of course! We had to do a lot of work to make that possible, but it's almost done.

How can you use this? Here's a simple example:

// create a script called AddressCluster
mywidget.findChild("_addr1").placeholderText = "Company";
mywidget.findChild("_addr2").placeholderText = "123 Main St, Suite 16";
mywidget.findChild("_addr3").placeholderText = "PR Urbanization";

This script sets "ghosted" prompts for your users to fill in the address fields with specific values. This can help you standardize the format of the addresses.

There are other possibilities, of course. We will write more complete documentation to describe what you can do and how to do it as we expand this capability.

Watch the xTuple Forums for the final release announcement. We'll also include a complete set of release notes in a blog post. Be sure you're subscribed to Watch Lists on the Forums for immediate emails and/or desktop notifications.

Gil Moskowitz

Director Software Development
Gil joined xTuple in 2005 to develop the first version of multi-currency support in our products. He helped xTuple transition from its original closed source OpenMFG product to the commercial open source company we are today. Before coming to xTuple, Gil worked for several large and small software companies in a variety of roles, including Informix Software, where he managed the database backup/restore utility group. He always advocates for, and delivers, high-quality products through improvements to the software development process. Ask about his other jobs next time you see him — ! He has a B.A. in Biology from Reed College and an M.S. in Computer Science from Old Dominion University.