Maximo

Maximo

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

 View Only
  • 1.  Issues updating Assignment Status on a Work Order

    Posted 11/04/20 07:51 AM

    When the user is starting the time on a Work Order using a timer, I want to update the Assignment to "STARTED" and then once the user taps on the timer to stop the time, if they use the "COMPLETE WORK" option, then I want to update the Assignment to "COMPLETE". I am having issues with the second piece of code saving the assignment status change to the database. Has anyone else ever updated Work Order Assignments?

     

    This piece of code in the file js.application.handlers.StopTimerHandler.js works to complete the Assignment. NOTE: There are errors when going right to "COMPLETE" from "ASSIGNED" for "BMXAA4636E - The finish date must be later than the schedule date" and that is why I am trying to set the Assignment to "STARTED" when the user first starts the timer.

     

    completeWorkAssignmentHandler: function(eventContext){
                     var woTimer = eventContext.getCurrentRecord();
                    var actualassignSet = eventContext.application.getResource("workOrder.assignmentlist");

                     // run other pause work tasks first
                    this.pauseWorkHandler(eventContext);         

                    // loop over all of the assignments, we only want to update the one assignment that is for the user
                    // and not the ones that are craft or anything else this goes from STARTED -> COMPLETE
                    for(var i=0;i<actualassignSet.count();i++){
                                  var assign = actualassignSet.getRecordAt(i);

                                    // if the assignment is assigned to the user and the status is started, then we can complete that
    if(actualassignSet.getRecordAt(i).get('laborcode') == woTimer.get('labor') && actualassignSet.getRecordAt(i).get('status') == 'STARTED'){

                                                    // set the new status here
                                                    assign.set('status','COMPLETE');
                                    }
                    }
    }

     

    So, I tried to add code that will update the Assignment from "ASSIGNED" to "STARTED", and this code works as far as it updates the Assignment and I can see the updated data in the debugger, but it never commits to the database.

     

    SetAssignmentToStarted: function(eventContext){
                   // get variables that we needed
                    var userLC = eventContext.actuallaborlist[0].laborcode;

                    // loop over all of the assignments, we only want to update the one assignment that is for the user
                    // and not the ones that are craft or anything else this goes from ASSIGNED -> STARTED
                    for (var i = 0; i < eventContext.assignmentlist.length; i++) {
                                    // if the assignment is assigned to the user and the status is assigned, then we can complete that
                                    if (eventContext.assignmentlist[i].laborcode == userLC && eventContext.assignmentlist[i].status == 'ASSIGNED')
                                                    // set the status on this record to started
                                                    eventContext.assignmentlist[i].status = 'STARTED';
                                    }
                    }
    },

     

    Any suggestions or ideas?

    Scott

     

     

     

     

     



    ------------------------------
    Scott Patterson
    SMS
    ------------------------------



    #MaximoAnywhere
    #Maximo
    #AssetandFacilitiesManagement


  • 2.  RE: Issues updating Assignment Status on a Work Order

    Posted 01/10/21 06:00 PM
    Edited by System Admin 08/22/23 04:41 PM

    Any luck?




  • 3.  RE: Issues updating Assignment Status on a Work Order

    Posted 01/15/21 04:29 AM
    Dear Scott, 

    Kindly troubleshoot the steps by checking the following:

    • Check the Maximo Anywhere Users Security Rights when you are performing some specific actions from Anywhere Application on MobileFirst
    • Debug the Code again by Checking the Passing arguments are correct after compiling the code
    • Check the OSLC Processing by POST/GET Method


    ------------------------------
    Adnan Sheeraz
    ------------------------------