Maximo

Maximo

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

 View Only
  • 1.  How to generate work order from PM using REST API

    Posted 16 days ago
    I need to create a Maximo work order from a Preventive Maintenance (PM) record using the REST API. I am using the built-in MXPM object structure. My understanding is that you need to use "_action=generateWorkorder" to invoke the action to generate the work order. When I do that, I get a 204 response, but no work order gets created. Are there other parameters or headers needed to get this to work?



  • 2.  RE: How to generate work order from PM using REST API

    Posted 16 days ago

    Why do You want to create WO from PM using REST? What is the case?



    ------------------------------
    Juris Flugins
    Expert IT Consultant
    TROIA d.o.o
    Jurmala
    ------------------------------



  • 3.  RE: How to generate work order from PM using REST API

    Posted 15 days ago
    My use case is for testing. I have a set of PMs and I need to create work orders multiple times from each PM for other tests. This is being done from Postman using a Runner collection.





  • 4.  RE: How to generate work order from PM using REST API

    Posted 15 days ago

    The other way to do this is to set up a new instance of the PMWogenCronTask and pass the instance_pm_sqlwhere parameter filled with your test subset. Seems a lot simpler than writing code.



    ------------------------------
    Bradley K. Downing , MBA
    Senior Solution Architect
    IBM
    Bakersfield
    ------------------------------



  • 5.  RE: How to generate work order from PM using REST API

    Posted 15 days ago

    Normally, the format would be something like this:

    POST https://<maximourl>/maximo/api/os/mxapipm/<restid>?lean=1&action=wsmethod:generateWork
    apikey: <apikey>
    x-method-override: PATCH
    properties: *

    ... but I don't see the "generateWork" action listed in the swagger documentation.

    If your use case is for testing, you might be able to write an automation script to run the Work Order Generation routine from a PM, and then call the automation script via the REST API in your test cases.

    Hope this helps,



    ------------------------------
    Alex Walter
    CIO
    A3J Group
    Tampa FL
    ------------------------------



  • 6.  RE: How to generate work order from PM using REST API

    Posted 15 days ago

    Alex,

    My use case is testing, and having an API endpoint implemented in an automation script is an acceptable solution. I wrote the script today, but I'm running into issues with the generateWork method on the PM mbo. It's saying the ASSET on the PM can't be used, even though I can generate the WO logged in as a user. I'm suspecting it's something about the Maximo user that is associated with the API key I'm using. However, it has full MAXADMIN permissions, so I'm not sure what's wrong. Maybe there's an issue with the SITEID or default insert site, if it isn't set up for the API user.



    ------------------------------
    Theo Pozzy
    ------------------------------



  • 7.  RE: How to generate work order from PM using REST API

    Posted 15 days ago

    Hi Theo,

    if it's for testing purposes only then I why don't you create quick-n-dirty REST API automation script which can do whatever you want?
    Just have a look at official MAS Manage Script Handler or Invoking script through Automation Script Handler GitHub documentation.
    You can pass PM reference as request parameter(s), find PM and call PM.generateWork() directly.



    ------------------------------
    If this post helps, please consider accepting it as a solution to help other members find it more quickly.

    Andrzej Więcław
    Maximo Technical SME
    ZNAPZ B.V.
    Wrocław, Poland
    ------------------------------



  • 8.  RE: How to generate work order from PM using REST API

    Posted 15 days ago
    Edited by Vijayalakshmi Mane 15 days ago

    Hey Theo,

    I did a quick check, and this method works for me. Here's a step-by-step on how to generate a work order from a PM using an automation script on the MXAPIPM object structure.

    1. Create an Automation Script for Object Structure MXAPIPM

    • This needs to be an Action Processing Script.

    • Name the action script: GENERATEWORKORDER

    Sample Script:

    from psdi.server import MXServer

    pmnum = request.getQueryParam("pmnum")

    siteid = request.getQueryParam("siteid")

    if pmnum is not None and siteid is not None:

        PMMboSet = MXServer.getMXServer().getMboSet("PM", request.getUserInfo())

        PMMboSet.setWhere("pmnum='" + pmnum + "' and siteid='" + siteid + "'")

        PMMboSet.reset()

        if PMMboSet is not None:

            PMMbo = PMMboSet.getMbo(0)

            if PMMbo is not None:

                PMMbo.generateWork(0, 0)

        PMMboSet.clear()

        PMMboSet.close()

    2. Configure the Action in the Object Structure

    • Go to the Object Structures application and open the record for MXAPIPM.

    • Under More Actions > Action Definition, create a new action:

      • Action Name: GENERATEWORKORDER

      • Implementation Type: Script

      • Script Name: Select the script you created in Step 1

    3. Test via REST API (Postman Example)

    PUT https://<hostname>/maximo/api/os/mxapipm?apikey=<APIKEY>&pmnum=1008&siteid=BEDFORD&action=GENERATEWORKORDER
    Request Body: (None - empty body)

    Hope this helps!



    ------------------------------
    Vijayalakshmi Mane
    Technical Consultant
    Bentley Systems Netherlands B.V.
    sHertogenbosch, The Netherlands
    ------------------------------



  • 9.  RE: How to generate work order from PM using REST API

    Posted 14 days ago

    That worked great! I just used the code as a direct API call script, and I'm sure adding at as action to an existing object structure would work equally well.

    Thank you so much for your help!



    ------------------------------
    Theo Pozzy
    ------------------------------



  • 10.  RE: How to generate work order from PM using REST API

    Posted 4 days ago

    Appreciate this answer!!



    ------------------------------
    Abdullah Blal
    Software Engineer
    Megasoft
    Giza
    +201155119254
    ------------------------------