H5 script examples for Infor M3, from a column sum to blocking a release

· Stewart Rutledge

Every M3 site has a list of small things that would make a screen better. A sum on a column so nobody exports to Excel to add it up. A name next to a number. A check that stops a mistake at entry instead of three days later in the warehouse. Most of them can be solved with an H5 script, the standard way to customize an M3 screen without changing M3 itself.

This article goes through what an H5 script is, five H5 script examples we've built on standard M3 panels, and the things worth knowing before you write one yourself.

What an H5 script is in Infor M3

An H5 script is a piece of JavaScript attached to an M3 panel. When the panel opens, the script runs, and from there it can:

  • read and change the fields on the panel
  • add its own buttons, fields, labels and list columns
  • react to what the user does, like pressing Enter or choosing an option
  • stop an action before it reaches M3, and say why
  • call M3 APIs to read or update data from other programs

An administrator deploys the script to M3, and then it's attached to a panel under Tools → Personalize → Scripts, for one user, a role or everyone. Users don't install anything and don't need any licence beyond M3.

What it usually takes

The script itself is often a few hours of work. Getting it there is the slow part: someone describes the problem, a consultant finds a solution, a developer reads into a process they've never worked in, builds it, deploys it, and it comes back not quite right because one person wrote the description and another read it. Three or four hours go into the spec and planning before anyone writes code, and the calendar time is days or weeks.

The examples below were each built with Loupe Code, from a short description and by pointing at the fields on the panel. We've noted the time and cost for each so you can compare.

1. Sum a column for the selected rows (OIS300)

Customer order lists are where people most often export to Excel just to add something up. This script adds a field above the OIS300 list and keeps it updated with the sum of a column for the rows the user has selected.

The prompt was "Sum the value of the column for all selected rows", with the column and the new field pointed out on the panel. A later version adds the total weight of the selected orders the same way. That one took under four minutes from opening M3 to a working preview, and cost €2.18.

2. A customer name next to the customer number (OIS300)

OIS300 shows the customer number, and people who don't know every number by heart have to open the customer to see who it is. This script adds a column with the customer's name, read from M3 for the rows on screen. The same script can add a warehouse name column next to the warehouse.

It reads the names for all visible rows in one request, so the list doesn't slow down as it gets longer.

3. Open a customer's orders from the customer (CRS610)

A button under the customer number on CRS610/E that opens OIS300 with that customer's open orders. It's a small thing, but it saves a trip through the menu many times a day for a customer service desk.

Placing the Open orders button on CRS610 and describing what it does

4. Block releasing an item without a purchase price (MMS002)

When an item is released in a warehouse without a purchase price from its supplier, the problem shows up much later, in purchasing or in costing. This script checks the supplier's purchase price when someone changes the item's status in MMS002, and stops the change with a clear message if there isn't one.

The prompt was "Block releasing items if the supplier doesn't have a purchase price", with the fields to check pointed out. About two to three minutes including the build.

The same pattern works for any validation at entry. We've built one that blocks order creation for customers missing a value in a custom field, where the user only had to point at the field on the order screen. Loupe Code found what the custom field is really called and where it's stored.

5. Update many order lines at once (OIS301)

Changing a reason code on thirty order lines means opening thirty lines. This script adds a button to OIS301 that opens a dialog with the valid reason codes, updates every selected line, shows a progress bar while it runs and ends with a clear status for each line. Built in a little over two minutes, for around €1.

Trying a script before anyone else sees it

With Preview in M3, the latest build runs in your own M3 session only. You attach the script to the panel once under Tools → Personalize → Scripts, refresh the panel, and from then on every preview on that panel runs the newest build. Nothing is deployed and nobody else is affected.

Preview in M3: attaching the script once, refreshing, and the button opening the customer's orders

Tips for writing your own H5 scripts

These apply to any H5 script, whoever writes it.

  • Scripts start again on every refresh. M3 unloads and runs the script again each time the panel is updated, for example after the user presses Enter. A value the script remembered from when the panel first opened is read again from what's on screen now. A validation that compares "before" and "after" should compare against what's saved in M3, not against what was on screen a moment ago.
  • Stop the action, then explain. A validation script should cancel the request before it reaches M3 and tell the user what to fix. A message after the fact doesn't help anyone.
  • Read in bulk. A column that calls an API once per row gets slow as the list grows. Read all visible rows in one request.
  • The script runs as the user. Every API call the script makes uses the user's own access, so a script can't give anyone more than M3 already allows.
  • Keep the source somewhere. A script that only exists as a deployed file in M3 is hard to change and impossible to review. Keep the source in your company's repository.

Questions we get

Do users need a licence to use a script?
No. A script built with Loupe Code is a standard M3 H5 script. Anyone with an M3 login can use it, in every environment you deploy it to.

Can we read and change the code ourselves?
Yes. Loupe Code writes TypeScript that's meant to be read, and the source is yours to keep in your own repository.

What does a script cost to build?
The examples above landed between about €1 and €2.50 each in AI usage, on top of the Loupe subscription.

Got a script that's been stuck on the backlog? Send it our way and we'll show you what Loupe Code does with it. Reach out at hello@loupeapp.net, or read more about H5 scripts in Loupe Code.

This article started as a post on LinkedIn. Join the conversation there.

Got something on your M3 backlog?

Send it our way and we'll show you what Loupe Code does with it, on your own M3.

H5 script examples for Infor M3, from a column sum to blocking a release