H5 – Requesting, Requested, RequestCompleted Events

Recently a customer tasked me with creating some scripts – the kicker, they wanted both Smart Office and H5 versions of the scripts.

The original scope for the scripts was pretty simple, so creating them wasn’t an issue – but as scope changed I encountered an issue – I needed to be able to cancel the Next event. As we’ve been able to do this since I started scripting with ISO, I figured that this wouldn’t be an issue – but it warranted some investigation before I committed.

Some quick checks of H5 and I couldn’t find the Requesting/Requested/RequestCompleted events – not so good. So I flicked an email off to one of the friendly ISO developers and was told that it had been recently added. The customer was running MUA, but I had another customer running Checking on the later version, I could see the following:

Which is a promising sign, digging a little deeper we find…

So I can be pretty confident that the later version has the functionality.

Cue the paranoia…just how do the events work under the H5 client? I didn’t want to assume, so I threw together a script to test the behaviour and sure that it worked just as it does on ISO.

See the script at the end of the post – but it will output the following.

The interesting thing that I noted was even though I appeared to be unsubscribing from the events, they would still fire until the panel was closed. If I commented out the unsubscription, then I would get multiple notifications. I’m not sure if this is working as designed, or I’m not unsubscribing correctly or I have found a bug – I’ve yet to get myself psychologically prepared to ask the question of support 🙂

Though customers are definitely conscious of Infors implied client direction, the H5 client development doesn’t have the maturity of Smart Office which is highlighted nicely by the only recent introduction of these events. And there has been many little things like determining which panel and program which just don’t seem as readily accessible – things which I often use extensively when I have scripts that run against multiple programs / panels.

That being said, the development tools within browsers make it a damn-sight easier to figure out what is going on – which if very attractive. And as I have mentioned in a previous post, there has been definite effort to make the development transition as painless as possible (and provides nice clues as to what is going on in ISO).

Anyways – in the screenshot below I have attached my script and have the browser development tools turned on so I can see the console output.

And finally the script itself…

**	Name:	jbc_TestRequest.js
**	Panel:	any
**	Description:
**		this script demonstrates the requesting/requested/requestcompleted events
**	Written by:
**		Scott Campbell (blog@potatoit.kiwi)
**	History:
**	20160427	SAC		* started

var jbc_TestRequest = new function ()
	var gController;
	var gDebug;
    this.Init = function(scriptArgs)
        var host = scriptArgs.controller.ParentWindow;
        var args = scriptArgs.args;
        var el = scriptArgs.elem;
        gDebug = scriptArgs.debug;
		gController = scriptArgs.controller;
        var content = cont.RenderEngine.Content;
        gDebug.WriteLine("jbc_TestRequest script was called");
		gController.Requesting.On(function (e) { this.onRequesting(e); });
		gController.Requested.On(function (e) { this.onRequested(e); });
		gController.RequestCompleted.On(function (e) { this.onRequestCompleted(e); });
    onRequesting = function (e) 
        gDebug.WriteLine("onRequesting was called");
		// comment out the line below to allow other events to fire
		//e.cancel = true;
    onRequested = function (e) 
        gDebug.WriteLine("onRequested was called");
    onRequestCompleted = function (e) 
        gDebug.WriteLine("onRequestCompleted was called");
		gController.Requesting.off(function (e) { this.onRequesting(e); });
		gController.Requested.off(function (e) { this.onRequested(e); });
		gController.RequestCompleted.off(function (e) { this.onRequestCompleted(e); });
This entry was posted in H5 Client. Bookmark the permalink.

2 Responses to H5 – Requesting, Requested, RequestCompleted Events

  1. norpe says:

    The Requesting, Requested and RequestCompleted events all return an object that you can use to unregister the events. You have to store these objects (which are just functions) in some kind of variable and call those functions in the handler for either the Requested or RequestCompleted event depending on your script. You could have variables for each unregister function or create a generic solution with an array of unregister functions for example.

    In your example you do something that would work in .NET but in JavaScript we don’t know that it is the same event handler function that is unregistered. It should also be noted that there are many ways to implement events in JavaScript and this solution might not be completely obvious.


    var unregisterRequestCompleted;

    this.Init = function(scriptArgs) {
    this.unregisterRequestCompleted = gController.RequestCompleted.On(function (e) { this.onRequestCompleted(e); });

    onRequestCompleted = function (e) {
    // Unregister events

    • potatoit says:

      Thanks Peter for the clarification – much appreciated, I got close on one my of iterations – but not close enough 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s