Maximo

 View Only

 Maximo Mobile for EAM Task Customization Help

Jump to  Best Answer
Tim Ferrill's profile image
Tim Ferrill posted Fri April 04, 2025 11:16 AM

Hello Maximo Community,

Hoping to get someone smarter than I to help me figure out what I'm missing in a Maximo Mobile customization I'm working on (Maximo Mobile for EAM 9.0.0).

The requirement is for the customer to be able to mark task completion as Yes, No, or N/A using a custom field.

Here's what I have so far, I used the completeWoTask() function from TaskController as the basis:

  async x_completeWoTask(record) {
    if (!this.page.state.taskDisabled) {
      this.page.state.taskDisabled = true;
    } else {
      return;
    }

    let isMobile = this.app.device.isMobile;

    let item = record.taskItem;
    if (item) {
      item.disabled = true;
      this.page.state.disableButton = true;
      this.page.state.currentTask = item.taskid;
      localStorage.setItem('scrollpos', window.scrollY);

      let taskds = this.app.findDatasource('woPlanTaskDetailds');
      let task = item;
      task.istaskdone_x = record.istaskdone_x;
      
      let incompTaskCount = [];
      
      try {
        let response;
        if (isMobile) {
          //Since mobile's response doesn't come from the server, just use localPayload
          response = task.woactivity[0];
        } else {
          response = await taskds.put(task);
        }

        if (response) {
          item.istaskdone_x = record.istaskdone_x;

          if (taskds && taskds.items) {
            taskds.items.forEach((item) => {
              let istaskdone_x = item.istaskdone_x;
              if (item.taskid && !(istaskdone_x === 'YES' || istaskdone_x === 'NO' || istaskdone_x === 'N/A')) {
                incompTaskCount.push(item._rowstamp);
              }
            });
            this.app.state.taskCount = incompTaskCount.length;
          }

          if (incompTaskCount.length >= 1) {
            if (!this.app.state.networkConnected && isMobile && incompTaskCount.length === 1) {
              this.page.state.itemToOpen = item.workorderid;
            } else {
              this.page.state.itemToOpen = '';
            }
            await this.getScrollPosition();
          }
          
          if(!incompTaskCount.length) {
            this.page.state.itemToOpen = '';
            this.page.state.doneButtonDisabled = false;
          }
          setTimeout(() => {
            this.page.state.taskDisabled = false;
            item.disabled = false;
          })
          const schPage = this.app.findPage("schedule") || this.app.findPage('approvals');
          let SchedulePageDS = this.app.findDatasource(schPage.state.selectedDS);
          if (SchedulePageDS) {
            await SchedulePageDS.forceReload();
          }

        }
      } catch (err) {
        item.disabled = false;
        this.page.state.taskDisabled = false;
        console.log(err);
      }
      this.page.state.disableButton = false;
      item.disabled = false;
    }
  }

This flags the records correctly in the UI, but doesn't update the database.

Thanks in advance for any help!

Edit: Looks like I was overthinking it. Thanks Ritesh! Love the simplicity.

Ritesh Ranjan's profile image
Ritesh Ranjan IBM Champion  Best Answer

Hi Tim,

We had done something similar. like we added a custom dropdown field for tasks having values such COMP, NO, NA. instead of different buttons.

And then wrote a simple custom code (attached to that dropdown field) in appcustomization.js instead of modifying taskcontroller.js file directly for saving the custom value.

async saveTask(event){
      if (event?.item?.wojo1 !== undefined) {    
    console.log("save on test");
    let ds = await event.app.findDatasource('woPlanTaskDetailds');
    ds.save();
    console.log("save was executed");  
  }
    }

Hope this helps.