Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only

MAS Mobile - Enhancing the "My Schedule" [TECHMOBILE] app to remember last selected option from dropdown query list.

  • 1.  MAS Mobile - Enhancing the "My Schedule" [TECHMOBILE] app to remember last selected option from dropdown query list.

    Posted 23 hours ago

    The "My Schedule" application in TECHMOBILE includes a dropdown list that mobile users rely on to choose which query should be executed to retrieve the Work Order list from Maximo/MAS Manage.
    However, there's a limitation: the selected option resets to the default value ("Assigned work") whenever the user closes the app and reopens it. This behavior can be frustrating for users who frequently work with a specific query.
    To address this, I'm sharing a simple customization (suggested by IBM) that allows TECHMOBILE to remember the last selected dropdown option for each user.

    Please note: The last selected option is stored in local storage and if the user reinstalls aplication, or performs a "Reset App" action from the Settings section, the stored selection will be lost.

    Use Case:

    1.The user logs into the mobile application and navigates to the My Schedule app.

    2.The user selects a specific option from the dropdown list, for example, "My work order".

    3.The user closes the application and later logs in again.

    4.Instead of reverting to the out-of-the-box "Assigned work" default, the dropdown now displays the option selected in step #2 "My work order".

    Customisation:
    1. /TECHMOBILE/src/AppCustomizations.js
    import SchedulePageController from "./SchedulePageController.js";
    
    class AppCustomizations {
     applicationInitialized(page, app) {
       this.page = page;
       this.app = app;
     }
    
     async pageInitialized(page, app) {
        this.page = page;
        this.app = app;
    
        if(page && page.name === 'schedule') {
            let persistentDropdownVal = localStorage.getItem("cMyLastSelectedDropdown");
            if(persistentDropdownVal) {
                this.page.state.selectedDS = persistentDropdownVal;
                this.app.state.selectedWoListDs = persistentDropdownVal;
            }
        }
     }
    
     async changeDropdownSelection(evt) {
        let schedulePageController = this.page.findController(
            (c) =>  {
                if (c instanceof SchedulePageController) {
                    return true;
                }
            }
        );
        if(schedulePageController) {
            localStorage.setItem("cMyLastSelectedDropdown", evt.selectedItem.id);
            await schedulePageController.loadWOListData(evt);
        }
     }
    
    }
    
    export default AppCustomizations;

    2. /TECHMOBILE/src/app.xml (replace on-change="loadWOListData" to custom one on-change="changeDropdownSelection")

    (...)
    <dropdown 
     slot="dropdown" 
     background-color="white" 
     selected-item="{page.state.selectedDS}" 
     id="rzvz4" 
     on-change="changeDropdownSelection" 
     hide-unselected-placeholder="true">
    (...)


    ------------------------------
    Bartosz Marchewka
    IBM Maximo Consultant
    AFRY
    ------------------------------