Developer ToolsFree generatorPDF, Excel, Word exportInfor M3All Infor M3 tools

Infor M3 H5 Script TypeScript Template Generator

This generator writes a TypeScript H5 script class that reads a field on an M3 panel, calls one MI transaction and shows the result on the same panel. It targets the H5 Script SDK structure used with M3 13.x on-prem: a class with a static Init entry point that receives the script arguments.

Fill in

Init runs when the panel loads; Requesting runs before Enter is sent.

Generated code
Download:

MMS001_ShowItemStatus.ts

// H5 script for MMS001/E: reads WBITNO, calls MMS200MI/GetItmBasic, shows STAT.
// Run mode: Init
class MMS001_ShowItemStatus {
    private controller: IInstanceController;
    private log: IScriptLog;
    private unsubscribeRequesting: Function;
    private unsubscribeRequested: Function;
    private static readonly RUN_ON: string = "Init";

    constructor(scriptArgs: IScriptArgs) {
        this.controller = scriptArgs.controller;
        this.log = scriptArgs.log;
    }

    public static Init(args: IScriptArgs): void {
        new MMS001_ShowItemStatus(args).run();
    }

    private run(): void {
        if (MMS001_ShowItemStatus.RUN_ON === "Requesting") {
            this.unsubscribeRequesting = this.controller.Requesting.On((e: IRequestingEventArgs) => {
                this.onRequesting(e);
            });
            this.unsubscribeRequested = this.controller.Requested.On(() => {
                this.detach();
            });
        } else {
            this.lookup();
        }
    }

    private onRequesting(e: IRequestingEventArgs): void {
        if (e.commandType === "KEY" && e.commandValue === "ENTER") {
            this.lookup();
        }
    }

    private detach(): void {
        if (this.unsubscribeRequesting) { this.unsubscribeRequesting(); }
        if (this.unsubscribeRequested) { this.unsubscribeRequested(); }
    }

    private lookup(): void {
        const value: string = this.controller.GetValue("WBITNO");
        if (!value) {
            this.log.Info("MMS001_ShowItemStatus: WBITNO is empty, nothing to look up");
            return;
        }
        const request = new MIRequest();
        request.program = "MMS200MI";
        request.transaction = "GetItmBasic";
        request.record = { ITNO: value };
        request.outputFields = ["STAT"];

        MIService.Current.executeRequest(request).then((response: IMIResponse) => {
            const item = response.item;
            const shown: string = item ? String(item["STAT"]) : "(no record)";
            this.log.Info("MMS001_ShowItemStatus: " + value + " -> STAT = " + shown);
            this.showLabel("STAT: " + shown);
        }).catch((response: IMIResponse) => {
            this.log.Error("MMS001_ShowItemStatus: MMS200MI/GetItmBasic failed: " + response.errorMessage);
            this.showLabel("Lookup failed: " + response.errorMessage);
        });
    }

    private showLabel(text: string): void {
        const label = new LabelElement();
        label.Name = "MMS001_ShowItemStatus_lbl";
        label.Value = text;
        label.Position = new PositionElement();
        label.Position.Top = 2;
        label.Position.Left = 60;
        label.Position.Width = 30;
        this.controller.GetContentElement().AddElement(label);
    }
}

Deploy and attach

1. Compile the TypeScript to JavaScript with the H5 Script SDK typings referenced (tsc, target as in the SDK samples).
2. Upload MMS001_ShowItemStatus.js in H5 Administration Tools > Scripts.
3. Open MMS001/E, then Tools > Personalize > Scripts, add script MMS001_ShowItemStatus and save.
4. Reload the panel and check the script log for the Info lines.

This is a starting point, not tested against your SDK build. Before deploying, check every name against the H5 Script SDK typings shipped with your H5 version: IScriptArgs, IInstanceController.GetValue, Requesting/Requested.On and the unsubscribe function they return, IRequestingEventArgs commandType and commandValue, MIRequest, MIService.Current.executeRequest, IMIResponse item and errorMessage, LabelElement, PositionElement and GetContentElement().AddElement. The panel field name ({{field}}) is the screen field, not the MI field: confirm it with the field help on the panel.

Get your H5 script reviewed

Send the generated script and your H5 version and we will check the API names, event handling and error paths before you deploy.

Optional. The tool and every export work without this. No spam.

Was this tool useful?

How to use it

Name the class after the program and purpose, enter the program and panel (for example MMS001/E), the screen field to read (the default WBITNO is an example; confirm the real name with field help on your panel), the MI program and transaction, the MI input field that takes the screen value and the output field to show. Choose Init to run when the panel loads, or Requesting to run each time the user presses Enter. The label position uses the panel grid (rows and columns), so start at the default and move it if it overlaps a field.

  • Keep one script per job; small scripts are easier to debug
  • Use Get transactions in scripts, never Add or Upd without a confirm step
  • Log with log.Info while testing and remove noisy lines afterwards

How the generated class is structured

H5 calls the static Init method with the script arguments. The constructor keeps the controller (the panel instance) and the log. run() either does the lookup immediately or subscribes to the Requesting event and filters for the Enter key; it also subscribes to Requested so both handlers are removed after the request, because H5 calls Init again when the panel reloads. lookup() reads the field with the controller, builds an MIRequest with program, transaction, input record and output fields, and executes it through MIService. The promise resolves with the response item, or rejects with an error message that the script logs and shows.

Worked example

On MMS001/E the script reads the item number field (confirm its screen name with field help), calls MMS200MI GetItmBasic with ITNO set to that value and asks only for STAT. If the item exists, the label shows STAT: 20 and the log records the value. If the item does not exist, GetItmBasic returns an error and the label shows the M3 message. Asking for only the output fields you need keeps the call small, which matters when the script runs on every Enter.

Gotchas

Screen field names differ from MI field names: panel fields carry a prefix (for example W1, WW or WB), while the API uses plain names such as ITNO. Event handlers that are not removed fire multiple times after a few panel reloads. Calls run as the logged-in user, so MI security and the user's company and division apply. Scripts that call transactions on Requesting add latency to every Enter; keep them fast or run them on Init. Test in a non-production environment and keep the compiled file and source together in version control.

Frequently Asked Questions

What is the entry point of an M3 H5 script?

A class with a public static Init method. H5 calls Init with the script arguments, which include the controller for the current panel instance, a log and the argument string configured when the script was attached. Most scripts create an instance in Init and keep the controller and log as members.

How do I call an M3 API from an H5 script?

Build an MIRequest with program, transaction, an input record and the output fields you need, then execute it through MIService, which returns a promise. Handle the resolved response item and the rejected error message. Calls run with the logged-in user's authority, so MI security applies.

Where do I upload and attach an H5 script?

Upload the compiled JavaScript file in H5 Administration Tools under Scripts. Then open the target program and panel, go to Tools, Personalize, Scripts, and add the script by name. Reload the panel to run it. Personalizations can be set per user, role or globally depending on your rights.

Do I need TypeScript to write H5 scripts?

No, H5 runs JavaScript. TypeScript with the H5 Script SDK typings catches wrong method names and types at compile time, which is why many teams write scripts in TypeScript and deploy the compiled JavaScript. Compile with the target used in the SDK samples for your H5 version.

If you would rather let users ask M3 these questions in plain English on your own servers, we can set up a private assistant that reads the same MI transactions.

ArchRay builder
Design the on-prem AI stack for Infor M3: model, GPUs, RAG pipeline, guardrails
See memory, speed and cost as you swap parts, then export the diagram. Free, in your browser.
Open the builder

Keep exploring

Free tools

ERP fixes and how-tos

Guides

AI on your ERP

Integrations

Software