1

i created a custom action in a Maximo app which opens a dialog box where the user can tick checkboxes to choose whether or not to display tabs in the app view.

If a checkbox is selected in the dialog box, the attribute's value is set to 1 and the tab is displayed. On unselect the value resets to 0 and the tab is hidden.

The cancel button triggers the "dialogcancel" mxevent in my custom dialog, but when I select a checkbox then click the cancel button, the value does not reset to 0 and the tab that should be hidden is displayed.

here's a sample of my xml :

<dialog datasrc="MAINRECORD" id="showrbean" label="Display tabs" savemode="ONLOADUNLOAD">
   <checkbox dataattribute="SHOWTAB_1" id="id_checkbox_SHOWTAB_1" label="Tab 1"/>
   <checkbox dataattribute="SHOWTAB_2" id="id_checkbox_SHOWTAB_2" label="Tab 2"/>
   <buttongroup id="showtabs_bookmarks_2">
      <pushbutton default="true" id="showtabs_1" label="Update" mxevent="updateTabs"/>
      <pushbutton default="true" id="showtabs_2" label="Cancel" mxevent="dialogcancel"/>
   </buttongroup>
</dialog>

The dialogcancel event doen't seem to be working, how can I reset my values on cancel ?

Thanks

Traian GEICU
  • 1,750
  • 3
  • 14
  • 26
erabi
  • 31
  • 2

1 Answers1

2

Received this answer on another forum which works perfectly :

Ah Okay, so what you've done is actually added the display attributes to the same record as the app is looking at.

So even though it's in a dialog you're editing the same record as you have on the screen so it's like unticking a box without loading a dialog and so you can come out of the record and it will ask you to save changes, you could click no and it would reset.

If you want to be able to have the dialog have the cancel option you have two options. #1 is probably the best one.

1 - create a new object which stores appname, tabname, display, and have your dialog look at that object using a relationship based on the appname. if you do that then it wont save it unless you click dialogok, so your changes wont persist on dialogcancel. You can also then use this on lots of apps, you'd just need to add the relationships and conditions on the tabs that look at the new object.

2 - instead of calling dialogcancel, call your own automation script from that action, which sets the values to their previous value, you can do this with inbuilt _previous suffix if you're using auto script variables showtab1 = showtab1_previous or if you dont want to use the variables you can get it by using the mbo.setValue("SHOWTAB_1", mbo.getDatabaseValue("SHOWTAB_1")). once you've set the values you can call service.closeDialog() although this does depend on your maximo version, i think 7.6.0.8 and above maybe

I tried option 2 in my AppBean class :

public int customDialogCancel() throws RemoteException, MXException {

        MboRemote currMbo = this.getMbo();

        currMbo.setValue("SHOWTAB_1", currMbo.getDatabaseValue("SHOWTAB_1").toString());
        currMbo.setValue("SHOWTAB_2", currMbo.getDatabaseValue("SHOWTAB_2").toString());

        this.clientSession.queueEvent(new WebClientEvent("dialogclose", this.app.getCurrentPageId(), null, this.clientSession));
        return EVENT_HANDLED;
    }
erabi
  • 31
  • 2
  • This describes the situation well. I think there is a caveat with the related object solution, in that I think it will still save that data on that related set, unless you reset the set or use a non-persistent set (which is usually the preferred solution for this). Also, I think interacting with the UI to close the dialog via an automation script requires Maximo 7.6.*1*.x. If you are in a bean class, then that isn't a concern. – Dex Jun 04 '20 at 18:21