Maximo

Maximo

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

 View Only
Expand all | Collapse all

Problem with Autoscript asking for User Input

  • 1.  Problem with Autoscript asking for User Input

    Posted Fri September 04, 2020 09:49 PM

    I have an autoscript that I'm developing that triggers on the work order status change, and checks to see if a meter reading has been entered recently. If not, it's supposed to ask the user if they want to enter one first. If the user says yes, then the status change should be canceled - otherwise, the status change should proceed. The problem I'm having is: the script does not respond to the user input. If I click yes or no (it doesn't matter), the message just pops up again, so it's in an infinite loop. Can someone help out here? The code is as follows.

    TIA Shannon

    --------------------------------------------------------

    mxServer = MXServer.getMXServer();

    currDate = mxServer.getDate()

    def no():

    logger.debug("WO-STATUS-EM: Continuing without meter reading.")

    mbo.changeStatus("WCMP",mxServer.getDate(),"",MboConstants.NOACCESSCHECK)

    def yes():

    logger.debug("WO-STATUS-EM: Cancelling WCMP status change in order to input meter reading.")

    mbo.

    errorgroup = 'workorder'

    errorkey = 'WCMP Status change cancelled.'

    #20

    def dflt():

    params=[status]

    service.yncerror("workorder","noMeterReadingEntered",params)

    def getDateDiff(timeDiff):

    milliseconds = 1000

    milliminutes = milliseconds * 60

    millihours = milliminutes * 60

    millidays = millihours * 24

    daysDiff = timeDiff / millidays

    hoursDiff = timeDiff/millihours

    minDiff = timeDiff / milliminutes

    if(daysDiff != 0):

    return int(daysDiff)

    #36

    cases = {service.YNC_NULL:dflt, service.YNC_YES:yes, service.YNC_NO:no}

    if (status == "WCMP" ) and siteid == "CANADA":

    if worktype in ["EM","CM","PM"]:

    logger.debug("WO-STATUS-EM: Work type is " + worktype)

    meterReading = mbo.getString("ASSET.PRIMARYMETER.LIFETODATE")

    meterDate = mbo.getDate("ASSET.PRIMARYMETER.LASTREADINGDATE")

    if meterReading != "":

    logger.debug("WO-STATUS-EM: Primary meter reading is " + meterReading)

    logger.debug("WO-STATUS-EM: Last Reading Date is " + str(meterDate))

    logger.debug("WO-STATUS-EM: Current Date is " + str(currDate))

    timeDiff = currDate.getTime() - meterDate.getTime()

    daysDifference = getDateDiff(timeDiff.longValue())

    logger.debug("WO-STATUS-EM: Days since last reading are " + str(daysDifference))

    #63

    if daysDifference<=7:

    logger.debug("WO-STATUS-EM: Setting WCMP meter reading to " + meterReading)

    mbo.setValue("WCMPMETER",meterReading)

    else:

    if interactive:

    x = service.yncuserinput()

    cases[x]()






    #Support
    #Maximo
    #AssetandFacilitiesManagement
    #SupportMigration


  • 2.  RE: Problem with Autoscript asking for User Input

    Posted Mon January 25, 2021 04:48 PM

    This product forum is intended for client to client collaboration.

    If you want to engage IBM Support, you should open a support case: https://www.ibm.com/mysupport/s/createrecord/NewCase






    #AssetandFacilitiesManagement
    #SupportMigration
    #Maximo
    #Support


  • 3.  RE: Problem with Autoscript asking for User Input

    Posted Mon January 25, 2021 04:54 PM

    ?? Yes, I'm aware that this is for client to client. Since this is an autoscript, there wouldn't be support for it anyway.






    #AssetandFacilitiesManagement
    #Maximo
    #SupportMigration
    #Support