Maximo

Maximo

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

 View Only
  • 1.  REST call to get all work orders where user has assignments on?

    Posted Tue June 17, 2025 09:49 AM

    I am trying to get a list of all work orders where the logged in user has assignments on. I was trying to do something like this but it does not seem to be working. 

    https://main.manage.site.maximo.com/maximo/api/os/mxapiwodetail?lean=1&oslc.select=wonum,description&workorder.showassignment.where=labor.personid="882664"&workorder.showassignment.domaininternalwhere=status="ASSIGNED"

    Does anyone know how I should go about this?



    ------------------------------
    Christopher Stewart
    ------------------------------


  • 2.  RE: REST call to get all work orders where user has assignments on?

    Posted Tue June 17, 2025 11:46 AM
    Edited by Bartosz Marchewka Tue June 17, 2025 11:46 AM

    Hi @Christopher Stewart

    I think you can achieve that by using saved query that is defined in MXAPIWODETAIL object structure. You can use this one ASSIGNEDWOLIST that is available out of the box, or you can create a custom one if you need.

    Sample REST call url:

    https://main.manage.site.maximo.com/maximo/api/os/mxapiwodetail?oslc.select=wonum,siteid,orgid&oslc.pageSize=100&savedQuery=ASSIGNEDWOLIST&
    &collectioncount=1&ignorecollectionref=1&lean=1

    To review saved query please navigate to MAS Manage application:

    1. Select "Integrations" -> "Object Structures" application
    2. Find MXAPIWODETAIL object structure definition
    3. Select "Query Definition" from "More Actions" section
    4. Find ASSIGNEDWOLIST using filter option. To create your custom one you can use "New Row" button but then please remember to set correct saved query name in weburl request.

    ------------------------------
    Bartosz Marchewka
    IBM Maximo Consultant
    AFRY
    ------------------------------



  • 3.  RE: REST call to get all work orders where user has assignments on?

    Posted Wed June 18, 2025 07:41 AM

    Thanks Bartosz. This works great with my apikey. What is the best way to pass through a personid or userid to get the records if I am using an service type apikey to connect?



    ------------------------------
    Christopher Stewart
    ------------------------------



  • 4.  RE: REST call to get all work orders where user has assignments on?

    Posted Thu July 03, 2025 08:53 AM

    When I try to do this:

    mxapiwodetail?oslc.pageSize=100&savedQuery=ASSIGNEDWOLIST&collectioncount=1&ignorecollectionref=1&lean=1&oslc.select=wonum,siteid,orgid&oslc.where=personid="878237891" I get the error

    "message": "BMXAA8781E - This is an invalid query term. The property personid is not found under the namespace http://jazz.net/ns/ism/asset/smarter_physical_infrastructure#. You must review and update the query clause to use the correct property name.",

    Any thoughts on what I can do to either pass the personid or userid through to get assignments assigned to a technician?



    ------------------------------
    Christopher Stewart
    ------------------------------



  • 5.  RE: REST call to get all work orders where user has assignments on?

    Posted Fri July 04, 2025 02:39 AM

    Hi Christopher,

    unfortunately you cannot just like that pass parameters to a OS saved queries created directly in the Object Structures application. These can only be parameterized using typical placeholders (ref. psdi.mbo.SqlFormat).
    The simplest way to achieve this is to implement saved query automation script, by following this piece of official documentation. Under the hood you need to construct the where clause yourself but at least you can access request parameters.



    ------------------------------
    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
    ------------------------------



  • 6.  RE: REST call to get all work orders where user has assignments on?

    Posted Mon November 10, 2025 07:56 AM
    Edited by Christopher Stewart Mon November 10, 2025 08:01 AM

    I am still struggling to get this working and I am hoping someone can help. 

    I have a script set up with a variable called USERID. I have this script as a saved script query in the MXAPIWODETAIL object structure. When I call the rest call I get a 200 response, but it seems to return all work orders, not the ones I have assignments on which should be 8 work orders from what the query returns. Any thoughts on what I am doing wrong? 

    REST Call:

    https://test.maximo.com/maximo/api/os/mxapiwodetail?oslc.select=wonum&oslc.pageSize=1&collectioncount=1&ignorecollectionref=1&lean=1&savedQuery=OSQUERY.MXAPIWODETAIL.ASSIGNMENTPERUSER&sqp:USERID="RWAKEMAN01"



    Variable:

    Variable


    Object structure query:

    OS Query


    Script:

    from psdi.mbo import MboConstants
    param_value = None
    
    if 'USERID' in globals() and USERID is not None:
        param_value = USERID
    else:
        userInfo = mbo.getUserInfo()
        param_value = userInfo.getUserId()
    
    whereClause = """
    (WOCLASS IN ('WORKORDER', 'ACTIVITY')) 
    AND HISTORYFLAG = 0 
    AND ISTASK = 0 
    AND SITEID = 'SU' 
    AND STATUS != 'COMP' 
    -- Equivalent of NVL(WORKTYPE, 'NONE') != 'PP'
    AND (WORKTYPE IS NULL OR WORKTYPE != 'PP') 
    AND EXISTS (
        SELECT 1 
        FROM ASSIGNMENT 
        WHERE 
            ASSIGNMENT.WONUM = WORKORDER.WONUM 
            AND ASSIGNMENT.SITEID = WORKORDER.SITEID 
            AND ASSIGNMENT.LABORCODE = :1  -- Binds to param_value
            AND ASSIGNMENT.STATUS = 'ASSIGNED'
    )
    """
    targetMboSet = mbo.getThisMboSet()
    
    targetMboSet.setWhere(whereClause)
    
    targetMboSet.setWhereParam(1, param_value)
    
    targetMboSet.setQbe(True)



    ------------------------------
    Christopher Stewart
    ------------------------------



  • 7.  RE: REST call to get all work orders where user has assignments on?

    Posted Mon November 10, 2025 10:01 AM

    Hey Christopher,

    I made some changes to your script and was able to retrieve the records successfully.

    1. The API request -> I didn't use quotes for the paramater (https://<maximo.test.domain>/maximo/api/os/mxapiwodetail?oslc.select=wonum,description&oslc.pageSize=10&collectioncount=1&ignorecollectionref=1&lean=1&savedQuery=OSQUERY.MXAPIWODETAIL.ASSIGNMENTPERUSER&sqp:USERID=TESTUSER&apikey=<apikey>)
    2. Script:

    from psdi.mbo import MboConstants

    from psdi.mbo import SqlFormat

    param_value = None

    if 'USERID' in globals() and USERID is not None:

        param_value = USERID

    else:

        userInfo = mbo.getUserInfo()

        param_value = userInfo.getUserId()

    whereClause = """

    (WOCLASS IN ('WORKORDER', 'ACTIVITY'))

    AND HISTORYFLAG = 0

    AND ISTASK = 0

    AND SITEID = 'BEDFORD'

    AND STATUS != 'COMP'

    -- Equivalent of NVL(WORKTYPE, 'NONE') != 'PP'

    AND (WORKTYPE IS NULL OR WORKTYPE != 'PP')

    AND EXISTS (

        SELECT 1

        FROM ASSIGNMENT

        WHERE

            ASSIGNMENT.WONUM = WORKORDER.WONUM

            AND ASSIGNMENT.SITEID = WORKORDER.SITEID

            AND ASSIGNMENT.LABORCODE = :1  -- Binds to param_value

            AND ASSIGNMENT.STATUS = 'ASSIGNED'

    )

    """

    targetMboSet = mboset

    sqf=SqlFormat(whereClause)

    sqf.setObject(1,"ASSIGNMENT","LABORCODE", param_value)

    targetMboSet.setWhere(sqf.format())

    Hope this helps! 



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



  • 8.  RE: REST call to get all work orders where user has assignments on?

    Posted Mon November 10, 2025 12:48 PM

    Thanks! I was able to get it to work with your changes/suggestions!.



    ------------------------------
    Christopher Stewart
    ------------------------------