Skip to Content

Modal Form Event handling?

I am using C# SAP UI+DI API 9.2 for SAP Business One 9.2 and trying to use the Modal Form pattern (shown in the examples, UI: 12.ModalForm). I have a form, that opens multiple modal forms, these would ask for some input and after the OK event, something would happen on the main form. I can make a model form, just like the sample, but my question is: How can I handle the OK or Close event? The modal form is displayed as a new form, the user can interact with the main form while a model one is open and I don't know If the modal is closed already.

Let's say my main form has a list of items from OITM. The user opens a modal form by clicking on a button on the main form. Selects an action, that should do something with the items (updating fields for example), presses OK on the modal form, which closes it. Now I should reload the list on the main form, to load the updated items. How would I do it? Can I catch the modal form OK event somehow and trigger the reload?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Oct 07, 2016 at 10:26 AM

    Hi Szabolcs,

    My recommendation would be to fire an event from your "child" form, that your "parent" form will catch and process.

    Pseudo example:

    class ParentForm {

    public void OpenChild()

    {

    var childForm = new ChildForm();

    childForm.OnInterestingEvent += ProcessInterestingEvent;

    childForm.Open();

    {

    private void ProcessInterestingEvent(object sender, EventArg args)

    {

    ... update the items

    }

    }

    class ChildForm {

    public event EventHandler OnInterestingEvent = delegate {};

    private void OnOKButtonPressed(ItemEvent e)

    {

    ...

    OnInterestingEvent(this, new EventArgs());

    }

    }


    Pedro Magueija


    LinkedIn Logo View Pedro Magueija's profile on LinkedIn
    Follow @pedromagueija on Twitter

    If this answer was helpful or correct consider marking it as such.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 07, 2016 at 10:29 AM

    Hi Szabolcs,

    Just a reminder, SAP implemented a proper Modal property for forms. You can use the FormCreationParams.Modality to mark a form as modal.


    Pedro Magueija


    LinkedIn Logo View Pedro Magueija's profile on LinkedIn
    Follow @pedromagueija on Twitter

    If this answer was helpful or correct consider marking it as such.

    Add comment
    10|10000 characters needed characters exceeded