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.
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.
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.
Related Tools
Infor M3 H5 Script Review Checklist
A review checklist for H5 Client scripts covering design, coding, security, testing and upgrade risk.
Developer ToolsInfor M3 ION API Gateway OAuth 2.0 Python Client Generator
Generate a Python script that loads your .ionapi credentials file, gets and reuses an OAuth 2.0 token, and calls an M3 MI transaction through the on-prem ION API Gateway.
Infor M3 & CloudSuiteInfor M3 MI API Transaction Call Generator
Fill in program, transaction and parameters to get a ready M3 REST call as URL, curl and a JavaScript fetch snippet.
Infor M3 & CloudSuiteInfor M3 Bookmark URL Generator
Generate M3 bookmark strings that open a given program on a specific record, with option and panel, for links and mashups.
More Developer Tools tools
See all- Infor M3 EXPORTMI Select Query Generator
- Infor M3 CSV to MI API Bulk Loader Script Generator
- Infor M3 MDBREADMI and Custom List API Design Worksheet
- Infor M3 EXPORTMI Extraction Call Volume Calculator
- SAP Sales Order ABAP SELECT Generator (VBAK, VBAP, VBFA)
- SAP Sales Order Create BAPI ABAP Generator (BAPI_SALESORDER_CREATEFROMDAT2)
- SAP ABAP Open Items SELECT Generator
- SAP ACDOCA SQL Query Generator
- SAP QM Inspection Lot ABAP SELECT Generator
Keep exploring
Free tools
- Infor M3 H5 Script Review ChecklistA review checklist for H5 Client scripts covering design, coding, security, testing and upgrade risk.
- Infor M3 Smart Office to H5 Script Migration ChecklistChecklist for moving Infor Smart Office scripts, mashups, shortcuts and personalizations to the M3 H5 client: inventory, classify, rewrite, test and decommission.
- Infor M3 CSV to MI API Bulk Loader Script GeneratorGenerate a Python loader that reads a CSV, maps columns to MI fields, calls one M3 transaction per row and writes a result file with the M3 message for every failed row.
ERP fixes and how-tos
- How to Add a Personalization Script to an M3 H5 PanelAdd a JavaScript personalization script to an M3 H5 panel using the MForms API: setup, panel/field events, save and deploy, and common scripting mistakes.
- Infor M3 SDK, MI APIs and REST API Documentation GuideDeveloper map of the Infor M3 SDK: MI programs, the REST API through ION API, authentication, example calls, and where to find the official documentation.
- Infor M3 Export to Excel: Lists, Report Output and the API RouteHow to export Infor M3 list and panel data and report output to Excel using the client export, the Excel add-in or the MI API, plus common limits and pitfalls.
Guides
- Infor M3 H5 Client Personalization and Scripting GuideWhat the Infor M3 H5 client is and how to tailor it: personalization layers, JavaScript scripts, bookmarks and deployment, without touching the Business Engine.
- Infor M3 Technical Architecture Explained Layer by LayerInfor M3 technical architecture explained: M3 Business Engine, Infor Grid, database tables, H5 client, and integration layers for on-prem and CloudSuite teams.
- Infor M3 API Toolkit: A Developer's Guide to MI Programs and MvxAPIBuild robust integrations with the Infor M3 API toolkit. Learn MI programs, MvxAPI patterns, and transaction handling for M3 13.4+ environments.
Integrations
- How to add AI agents to Infor M3How to add AI agents to Infor M3: a tool layer over MI programs and ION, read-first workflows for POs, MO and CO exceptions, and human approval on writes.
- How to build an MCP server for Infor M3How to build a Model Context Protocol server for Infor M3: which read-only tools to expose over MI programs, ION or on-prem auth, transports, scoping and audit.