Maximo Integration

Expand all | Collapse all

Scripting Yes No Dialog return -1

  • 1.  Scripting Yes No Dialog return -1

    Posted Thu August 13, 2020 12:14 PM
    Hi, I kept having the same result when I use the Yes No Dialog box to take the userinput.

    My script is used by a WF. In the log I have an error thrown but I don't know why ! My message is shown to the user but either he clicks YES or NO , I have -1 as an answer so neither the yes or no function is called

    Here is my code (x is always equals to -1):

    def yes():
    # handle YES button press
    service.log("Button YES Pressed")

    def no():
    # handle NO button press
    service.log("Button NO Pressed")

    def dflt():
    # display the initial message
    service.yncerror("safety","PSAnnule")

    cas = {service.YNC_NULL:dflt, service.YNC_YES:yes, service.YNC_NO:no}
    if interactive:
    x = service.yncuserinput()
    service.log("User input: "+str(x))
           cas[x]()


    Log

    Can someone can tell my why ?

    Thank you




    ------------------------------
    Mathieu Guilmette
    ------------------------------


  • 2.  RE: Scripting Yes No Dialog return -1

    Posted Fri August 14, 2020 03:32 PM
    Hi Mathieu

    This is using the error message prompt up to get user input, so the error message in the log is normal.

    For the code execute, the first time when enter the code, which is nothing input and then call the function dflt, therefor always get -1 for the code when execute, and the correct code for get user input you need to change the function dflt code like below

    def dflt():
       # display the initial message
       service.log ("DFLT")
       service.yncerror("CUST","ConfirmBox")


    and also create a "CUST" message group with "ConfirmBox" under message on database configuration.

    that you will see an dialog box when the script run




    ------------------------------
    Jason Pun
    Technical Consulant
    Lexco
    (852) 2332 3262
    ------------------------------



  • 3.  RE: Scripting Yes No Dialog return -1

    Posted Thu August 20, 2020 02:57 PM
    Hi, the message works well. but once I see it, even if I click on  YES or NO. The message popback and I can't go out of this loop.

    the same thing happens to me using it on Attribute launchpoint Workorder.Status.

    Here's my complete script for my WORKORDER.STATUS launchpoint:
    https://pastebin.com/U4UNzriG

    ------------------------------
    Mathieu Guilmette
    ------------------------------



  • 4.  RE: Scripting Yes No Dialog return -1

    Posted Fri August 21, 2020 08:01 AM
    Work Order status will be an infinite loop (you can select cancel if you enabled it to exit the loop, but can't select yes or no) and I assume workflow has the same problem. On the Work Order status flow I opened a case with IBM in December of 2018 and it's working as designed. Essentially, they said we could put it on WOCHANGESTATUS but due to the way it's going from the WOCHANGESTATUS to WORKORDER & WORKORDER is executing additional validation it enters an infinite loop and there's no way to avoid that.

    ------------------------------
    Steven Shull
    Director of Development
    Projetech Inc
    Cincinnati OH
    ------------------------------



  • 5.  RE: Scripting Yes No Dialog return -1

    Posted Fri August 21, 2020 09:10 AM
    So what should be the solution if I want that the user confirm is action even if a task isn't complete ? I looked at the WOCHANGESTATUS table and there is no SITEID so I don't know how to create my relation to WORKORDER and not use only WONUM

    ------------------------------
    Mathieu Guilmette
    ------------------------------



  • 6.  RE: Scripting Yes No Dialog return -1

    Posted Fri August 21, 2020 09:39 AM

    In a simple scenario (not on the list tab), the owner MBO of the WOCHANGESTATUS is your work order. So you could do something like:

    ownerMbo=mbo.getOwner()

    if ownerMbo and ownerMbo.isBasedOn("WORKORDER"):
        # logic here

    List tab is more problematic if not action based to get the selected record(s).



    ------------------------------
    Steven Shull
    Director of Development
    Projetech Inc
    Cincinnati OH
    ------------------------------



  • 7.  RE: Scripting Yes No Dialog return -1

    Posted Fri August 21, 2020 01:29 PM
    Hi!

    It works fine with the code you provided !

    Thank you very much !

    ------------------------------
    Mathieu Guilmette
    ------------------------------



  • 8.  RE: Scripting Yes No Dialog return -1

    Posted Wed August 26, 2020 12:48 PM
    Hi,

    Finally it's not working that much ! It's working when I use the 'Change Status' option and then select one of the status that enters in the script ('COMPLETE') but it's not working when I use the 'Complete WorkOrder' in the toolbar because it doesn't trigger my trigger (WOCHANGESTATUS.STATUS) (on change). I tried a launchpoint on the validation of the object WOCHANGESTATUS, but the looping message came back.

    Do you have any other ideas ?

    Thank you

    ------------------------------
    Mathieu Guilmette
    ------------------------------



  • 9.  RE: Scripting Yes No Dialog return -1

    Posted Wed August 26, 2020 12:59 PM
    Try switching your attribute launch point from "validate" to "run action". I did a quick test in our 7.6.1.2 environment (just throwing an error, not yes/no/cancel) and that caused my script to fire properly. Hopefully that works for you.

    ------------------------------
    Steven Shull
    Director of Development
    Projetech Inc
    Cincinnati OH
    ------------------------------



  • 10.  RE: Scripting Yes No Dialog return -1

    Posted Wed August 26, 2020 01:14 PM
    Indeed, it's seems to be all good ! thank again

    ------------------------------
    Mathieu Guilmette
    ------------------------------



  • 11.  RE: Scripting Yes No Dialog return -1

    Posted Mon November 23, 2020 11:08 AM
    You are Amazing guys!
    I had the same issue with the loop, but LP for WOCHANGESTATUS is perfect workaround.
    Thanks so much!