The RequestCompleted event is really quite nifty, it provides some quite useful events.

The subscribed events has an argument with an object of RequestEventArgs, this has two very useful members. CommandType and CommandValue.

CommandType is defined in the static object MNEProtocol. Looking at the mforms::MNEProtocol in Visual Studios Object Browser we can see the values.

The items that start with CommandType (oddly enough) correspond to the RequestEventArgs.CommandType.

The RequestEventArgs.CommandValue corresponds to MNEProtocol.CommandValue

Below is some code that shows the messages and the values.

import System;
import System.Windows;
import System.Windows.Controls;
import MForms;

package MForms.Jscript
class RequestTest
public function Init(element: Object, args: Object, controller : Object, debug : Object)
// subscribe to our event

public function OnRequestCompleted(sender: Object, e: RequestEventArgs)
// display a messagebox with the event name
MessageBox.Show("OnRequestCompleted(): '" + e.CommandType + "' = " + e.CommandValue);

I saw a question about how to monitor for the Next event. Using the code above and selecting Next you’ll see the event CommandType of KEY which relates to CommandTypeKey and then a CommandValue of ENTER which relates to KeyEnter. So we just need to monitor the RequestCompleted event, look for a CommandType == CommandTypeKey and CommandValue == KeyEnter and then add your code.

Eg. Something like this:

if((e.CommandType == MNEProtocol.CommandTypeKey) && (e.CommandValue == MNEProtocol.KeyEnter))

Don’t forget to remove your event handler when you are finished šŸ™‚

Incidentally, you can download a free version of Visual Studio Express for free.

Have fun!

This entry was posted in Development, M3 / MoveX. Bookmark the permalink.

6 Responses to RequestCompleted

  1. maxric says:

    Hi Scott,

    I am a beginner in creating javascript for LSO but i have red and learn a lot on your site. May i ask you a question ? Here is the context… I have a specific transaction in M3, let’s call it ZGT010. This program launches a panel with a classic subfile; there is only B and E screens available. The purpose of the script is the following : click on a button in ZGT010/B and select the first row in the list, simulate the “modifiy” key (LSTOPT = 2 – ZGT010/E is then displayed), press ENTER (when pressing this key, the javex program creates records in OIS017/OIS021 so it can be quite time consuming, several seconds depending on the number of items to add in OIS021), then select the second record in ZGT010/B and do the same process but only when the first one is finished… Of course i have to handle pagedown() simulation but it’s another story…

    I tried to use the MformsAutomation and it works but i must launch one ZGT010 program per row in the list… when reading the first 33 rows before page down, i must open 33 ZGT010… that’s not the solution. I may have up to 1500 records in the subfile. LSO will crash !

    I am working on the RequestedCompleted event as you say that we can wait for the first process to be completed before launching the next one. I did not well understood the purpose of the MNEProtocol.CommandValue but i tried to use the RequestedCompleted event with only the first three rows.

    In the OnClickButton function, i have created a “for” loop this way :
    for (k=0;k<3;k++)
    var item : Object = list.Items[k];
    list.SeletedIndex = k;

    When key "2" is pressed, the RequestedCompleted event is called.
    In the OnRequestedCompleted function, i am testing e.CommandeType=LSTOPT and e.CommandeType=2. If so, controller.PressKey("ENTER") in order to validate the ZGT010/E screen.

    It's working for one row if i get rid of the loop "for" but it is only working for the last value of "k" (k=2 in this case) when the loop exists.

    Do you have any idea ? Thank you.

    ps : sorry for my bad english, it's not my native language

    • potatoit says:


      if you have a large amount of records you’ll find that using WebServices is a better option.

      But the issue that you are having at the moment…you mention that in the OnClickButton() you have a loop through the first three rows, calling option 2.
      There are a few problems doing that…take a look at:
      which discusses what happens when events occur. In short, typically when an event occurs the panel is redrawn and a new instance of your script associated with the redrawn panel (assuming that you script is associated with the new panel). If you aren’t cleaning up and handling the disassociation of the events and you have large number of records then your script will bleed memory quite quickly – which is what I expect is happening in the instance where you say LSO crashes after 1500 records – you can look at TaskManager to see how much memory LSO has when it crashes, I’m guessing around 1.5gig.

      In your example you wouldn’t have a loop, you’d only call the first controller.ListOption on the first row, then handle all of the subsequent rows in the the OnRequestCompleted event – the challenge then becomes keeping track of which row you are working on.

      But as I say, you’re probably better off looking at calling a WebService from a jscript – the performance with large numbers of records will be a lot better and probably less complex than working with the panels directly in a jscript.

      Unfortunately not a terribly helpful answer…but…


  2. maxric says:

    Hello Scott. Thank you for your answer. The link is quite interesting and all is a problem of timing. I was working on another script those days and i faced to the same problem. The goal of the script was to validate user input data on screen MMS130/A after ENTER key has been pressed, making a check on some info on the item record, on the current user profile and allowing the user to go further if the test was ok (MMS130/E). The OnRequesting event is launched as soon as the ENTER key is pressed; a MIWorker process retrieves the desired information from MITMAS but in asynchronous mode…and the script always reach the end of OnRequesting function before you can even get the result of the API (e.Cancel can never be equal to true in this case). I thought there was no way to do it but i found some interessant information on INFOR blog about Jscript. I am getting aware of how the script work in those cases. Your idea to write debug line in a file is really helpfull to understand Jscript logic. Thanks again !

  3. Kiran says:

    How to set the values on any type of text or combobox or checkbox on M3 Panel on basis of some change on panel?
    Please help if any one can.

    • potatoit says:

      Hi Kiran,

      there are a number of examples on getting information from controls on a panel in this blog and the other blogs that I reference. There are also several examples in the InfoCenter that you can install through LCM or the M3 Developer PDF.

      Basic premise is that you use the ScriptUtil.FindChild() method to get the control – from there you can retrieve or set the properties. documents the WPF controls (which Smart Office users) with the methods and properties that you can use.

      The post here shows how to set properties against a TextBox based on the values a user entered – it demonstrates have to retrieve the controls and how to set their properties and how you can cancel events.


  4. Thomas Bateup says:

    Thanks for this – it came in very handy

Leave a Reply

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

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

Facebook photo

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

Connecting to %s