Maximo Open Forum

 View Only
Expand all | Collapse all

Generate a list of workorders that contain attachments directly in Maximo

  • 1.  Generate a list of workorders that contain attachments directly in Maximo

    Posted 11-17-2023 15:03

    Hello guys!

    Maximo 7.6.1.3 here. Supervisors want to be able to generate a list of workorders that contain attachments. They want to be able to generate that list as part of the workorder application or directly through their own start center. SQL query is pretty simple and it gives me the expected result but according to you experience what is the simpliest way to deploy that feature? Automation Script?

    Thanks in advance.

    Danny


    #Administration
    #Customizations
    #MaximoUserGroups

    ------------------------------
    Danny Cordeau
    Universite de Sherbrooke
    ------------------------------


  • 2.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 11-20-2023 09:15

    Easiest would be to take your SQL and make it a Saved Query; and make that Saved Query public.  That way your users can get to it in Work Order Tracking, and a Result Set portlet could be configured.

    The downside to that is, of course, that if only some of your users should have access to the Query, there's no easy way to share the Query with just a group of users.  When that happens, you'd have to save the query, go into the database backend and update the owner of that query on the QUERY table (not that backend updates are recommended! And that's assuming you have backend access. . .), then create the query again, backend update that to the next owner, repeat.  Or, give (temporary, if they don't normally have it) access to these users to the WHERE clause, help them set up the query, then remove their WHERE clause access if applicable.



    ------------------------------
    Travis Herron
    Pensacola Christian College
    ------------------------------



  • 3.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 11-20-2023 09:19

    Hello Danny, can you convert your sql clause to a Maximo Where Clause and then save it as a query for the users to run themselves.  Once it is saved as a query in the work order application, you could also put a resultset on their start center.  (Work Orders with Attachments).



    ------------------------------
    Stephen Hume
    Sheffield Scientific LLC
    ------------------------------



  • 4.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 11-20-2023 09:30

    workorderid in (select ownerid from doclinks where ownertable='WORKORDER') 

    You can also limit it to only open work orders by adding "and historyflag = 0" to the query.



    ------------------------------
    Stephen Hume
    Sheffield Scientific LLC
    ------------------------------



  • 5.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 11-20-2023 10:14

    Hi Stephen,

    Here is my SQL Query :

    SELECT wonum,
    description,
    status,
    workorderid
    FROM workorder
    WHERE workorderid IN (SELECT ownerid FROM doclinks WHERE ownertable = 'WORKORDER')
      AND workorder.status IN ('ASSIGNÉ', 'ENCOURS')

    That query was converted to a Where Clause, based on your previous post (thanks!) :

    workorderid in (select ownerid from doclinks where ownertable='WORKORDER') and status in ('ASSIGNÉ','ENCOURS')

    I will now save my query and make it available for my supervisors.

    Thanks guys for your help!!

    Danny



    ------------------------------
    Danny Cordeau
    Universite de Sherbrooke
    ------------------------------



  • 6.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 20 days ago
    Edited by Erin Pierce 20 days ago

    Sorry to hijack this thread but I'm looking for the exact opposite. Trying to generate a list of Workorders that do not have a document attached in the document column on the doclinks table.

    I've modified it to the best of the ability for my situation, but getting no results or a syntax error message.

    ((status = 'CAN' or status = 'CLOSE' or status = 'COMP')  and ((upper(description) like '%A LEVEL%'))
    
    AND EXISTS (SELECT 1
    FROM workorder
    WHERE WONUM IN (SELECT 1 FROM doclinks WHERE ownertable = 'WORKORDER')
      AND DOCUMENT IS NULL)



    ------------------------------
    Nathan Frail
    FedEx
    ------------------------------



  • 7.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 20 days ago

    The following would simply find Work Orders that do not have a direct attachment (that is to say, I'm not considering inherited attachments).  Looks like you have some further filtering (status, description, etc.) to then add to this:

    SELECT * 
    FROM workorder 
    WHERE workorderid NOT IN (SELECT ownerid FROM doclinks WHERE ownertable = 'WORKORDER')


    ------------------------------
    Travis Herron
    Pensacola Christian College
    ------------------------------



  • 8.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 20 days ago

    Thanks Travis! Though I'm not sure the "workorderid" is valid for our application of Maximo, but I definitely could be wrong. Also, the further filtering for status and description you mention is performed earlier in the query, could that be causing my errors/lack of results?

    Here is another variant I tried but I'm a novice at this so I may be way off.

    (((status = 'CAN' or status = 'CLOSE' or status = 'COMP') and ((upper(description) like '%A LEVEL%')) and exists (
      select 1     -Also tried select * and select document-
      from doclinks
      where document is null))



    ------------------------------
    Nathan Frail
    FedEx
    ------------------------------



  • 9.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 20 days ago

    The workorderid is the true GUID field on the WORKORDER table.  Generally we like to think of WONUM, but that is only unique to the Org, I believe.  If you have multiple Orgs in your Maximo implementation, there could be multiple Work Orders with the same WONUM, but each one pertaining to a different Org.

    Anyways, try this:

    (status = 'CAN' or status = 'CLOSE' or status = 'COMP') and upper(description) like '%A LEVEL%' and workorderid NOT IN (SELECT ownerid FROM doclinks WHERE ownertable = 'WORKORDER')



    ------------------------------
    Travis Herron
    Pensacola Christian College
    ------------------------------



  • 10.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 20 days ago

    Fantastic! That did it!

    Just out of curiosity, why doesn't my "exists" clause that looks for NULL document column records in the doclinks table not work?

    I've used an almost identical where clause in another screen with great success.



    ------------------------------
    Nathan Frail
    FedEx
    ------------------------------



  • 11.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 20 days ago

    At least in my environment, with 106,000 entries in the doclinks table. . .the DOCUMENT column is never null.  Even if the user doesn't provide a value, Maximo should dynamically populate that field.



    ------------------------------
    Travis Herron
    Pensacola Christian College
    ------------------------------



  • 12.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 20 days ago

    Ahhh, that explains why I sometimes my query (if I had the syntax correct) would populate a list of no records, as opposed to an error. Thanks again Travis!



    ------------------------------
    Nathan Frail
    FedEx
    ------------------------------



  • 13.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 20 days ago

    (I tend not to instinctively use EXISTS, though it's probably more efficient. . .)

    If you want to write the same thing using EXISTS, it'd be like this:

    (status = 'CAN' or status = 'CLOSE' or status = 'COMP') and upper(description) like '%A LEVEL%' and not exists (select 1 from doclinks where ownertable = 'WORKORDER' and workorderid = ownerid)


    ------------------------------
    Travis Herron
    Pensacola Christian College
    ------------------------------



  • 14.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 20 days ago

    OK understood. Now using that same where clause (admittedly off topic of Workorders), trying to find count books with no attachment.

    Maximo accepts the query, but populates a list (smaller than all records) but some contain documents and some don't.

    ((status = 'COMP' and siteid = 'FXFRTSID') and countbooknum not in (select ownerid from doclinks where ownertable = 'PLUSTCB'))


    ------------------------------
    Nathan Frail
    FedEx
    ------------------------------



  • 15.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 20 days ago

    Hmm, can't say with authority, since Count Books seems to be something in one of the Maximo add-ons that I don't have.  My guess here is, like WONUM and WORKORDERID earlier in the discussion, maybe COUNTBOOKNUM isn't the GUID on the PLUSTCB table.  There's probably a field (that you'd never see in the UI) called COUNTBOOKUID or COUNTBOOKID.



    ------------------------------
    Travis Herron
    Pensacola Christian College
    ------------------------------



  • 16.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 19 days ago

    Hi all,

    There is no need to guess.  Go into the underlying object to the application (go into Application Designer to find that out), and the OWNERTABLE=(The OBJECT value) and the OWNERID = (The Unique Column).  You cannot guarantee that UID for the object uses this format <OBJECT> + 'UID'.  It should but doesn't and this is why until you know, you should do look it up.



    ------------------------------
    Craig Kokay
    Principal Consultant
    COSOL

    email: craig.kokay@cosol.global
    #IBMChampion
    ------------------------------



  • 17.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 19 days ago

    Hi Craig, Unfortunately I don't have access to the Application Designer as I am just an end user of Maximo. I am able to see the OWNERTABLE = PLUSTCB, but I can't see the Unique Column name, and using COUNTBOOKID gave me an error message.



    ------------------------------
    Nathan Frail
    FedEx
    ------------------------------



  • 18.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 18 days ago

    I believe Craig meant to say "Database Configuration" rather than "Application Designer".  But if you don't have that either, you can query MaxTable for the UniqueColumnName.  For example,

    SELECT TableName, UniqueColumnName FROM MaxTable WHERE TableName = 'COUNTBOOK' ;

    By the way, the majority of table in Maximo have the UniqueColumnName as TableName + "ID", not + "UID", unless an attribute/column already existed with that name for the Primary Key.  For example, in the Person table, "PersonID" is the attribute/column that the user sees so the Unique Column Name is "PersonUID", but on the MaxUser table, the attribute/column that the user sees is "UserID" so the Unique Column Name is "MaxUserID".

    I agree with Craig, that + "UID" across the board would make more sense but IBM (or MRO Software) did not apparently think so when they added the Unique Columns to every table in Maximo 6.



    ------------------------------
    Julio Hernandez
    Ergonare, Inc.
    ------------------------------



  • 19.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 19 days ago

    Hi Travis,

    I would encourage the use of EXISTS of an IN statement.  It's all to do with indexing, do an Explain Plan in a SQL tool and have a look at the cost and the indexes.  In almost all cases the EXISTS is far more efficient.



    ------------------------------
    Craig Kokay
    Principal Consultant
    COSOL

    email: craig.kokay@cosol.global
    #IBMChampion
    ------------------------------



  • 20.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 19 days ago

    The "Document IS NULL" will not work because you're reading the DocLinks table and the Document will normally not be NULL there.  However, if you did a LEFT OUTER JOIN between the WorkOrder and DocLinks table, then it would work.  For example:

    SELECT WO.* FROM WorkOrder WO LEFT OUTER JOIN DocLinks DL ON DL.OwnerID = WO.WorkOrderID and DL.OwnerTable = 'WORKORDER'

    WHERE DL.DocLinksID IS NULL

    and WO.Status IN (...

    I checked DL.DocLinksID instead of DL.Document in case your system allows DocLinks.Document to be NULL.  The DocLinksID will always be popuilated on DocLinks records so checking for it being NULL will give you all the WOs where no DocLinks record was found for the WO.



    ------------------------------
    Julio Hernandez
    Ergonare, Inc.
    ------------------------------



  • 21.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 19 days ago

    Hi Nathan,

    The doclink not give you what you want as there is not relationship established between the WORKORDER and DOCLINK.  Travis is correct.

    In the DOCLINK table, the document may come from any number of sources, but the linking ID is the OWNERID field, but should be further qualified with the OWNERTABLE which is that data source from the record.  If the source is SR, the OWNERTABLE = 'SR', if the work order, then it is OWNERTABLE = 'WORKORDER'.  Equally for the SR the OWNERID = 'TICKETID' or for the work order OWNERID = 'WORKORDERID'.  So, I'm not sure why you would say that 'workorderid' is not valid.

    Hope that helps.



    ------------------------------
    Craig Kokay
    Principal Consultant
    COSOL

    email: craig.kokay@cosol.global
    #IBMChampion
    ------------------------------



  • 22.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 19 days ago

    Craig, thank you for further explanation. I am very new to SQL and Maximo and as an end user, writing query isn't my primary job role, but people like you and Travis have helped so much already. I didn't know if 'workorderid' was valid because I simply couldn't find a field that indicated such, I figured someone would correct me.



    ------------------------------
    Nathan Frail
    FedEx
    ------------------------------



  • 23.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 19 days ago

    Hi Nathan

    The query was never going to work because in the exists never had the link back to the work order.  I have rejigged it, though it's still not technically correct.  You have got historyflag = 0, yet you are wanting to include the CAN status.  Whenever a work order goes to CAN, it automatically is tagged as historyflag =1, and so would never be included in your query.  At what stage in the work order lifecycle are you actually looking to run the query against.


    (
    woclass in ('WORKORDER', 'ACTIVITY') 
    and historyflag = 0 
    and istask = 0 
    and siteid = 'xxxxxxxxxxxxxxx'
    and status in ('CAN', 'CLOSE', 'COMP')
    and upper(description) like '%A LEVEL%' 
    and 
        not EXISTS 
        ( 

                  SELECT 1 
            FROM doclinks 
            WHERE ownertable = 'WORKORDER'
            and ownerid = workorder.workorderid
        )
    ;



    ------------------------------
    Craig Kokay
    Principal Consultant
    COSOL

    email: craig.kokay@cosol.global
    #IBMChampion
    ------------------------------



  • 24.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 19 days ago

    Hi Craig, yeah I ended up realizing I had some conflicting lines in the where clause and have since adjusted it accordingly. The end result I was looking for was all workorders in COMP status, the "A Level" description that do not have an attachment. Travis was able to help me out with that. Though I do have another question regarding filter this further into a date range. Specifically prior week Wednesday 12:00am - Tuesday 11:59pm.

    Here's what i've come up with but it's not running all the way to Tuesday 4/9/24 @ 11:59:59pm

    It lists all records from 4/3 @ 12:00am through Tuesday-24hours. So, any records completed after 6pm last night lets say, aren't populating.

    ((status = 'COMP' and upper(description) like '%A LEVEL%' and siteid = 'FXFRTSID' and (worktype = 'PM') and plustreason = '08') and workorderid not in (select ownerid from doclinks where ownertable='WORKORDER') and (statusdate between trunc(sysdate-7) and sysdate-1)) and ((plustrepord = 0))


    ------------------------------
    Nathan Frail
    FedEx
    ------------------------------



  • 25.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 18 days ago

    Hi Nathan,

    You didn't put the "TRUNC" around the "SYSDATE - 1".  You referred to wanting it go through the end of the day on Tuesday, 4/9, and I assume you're saying that because today is Wednesday, 4/10.  Assuming you want to list WOs whose Status changed during the 7 days ending yesterday, then you should say "(Status BETWEEN TRUNC(SYSDATE - 7) AND TRUNC(SYSDATE))" without the "-1".



    ------------------------------
    Julio Hernandez
    Ergonare, Inc.
    ------------------------------



  • 26.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 18 days ago
    Edited by Nathan Frail 18 days ago

    That did it! Though due to some apparent time difference in our local-session time compared to server-time it lists records from 1am to 1am instead of midnight to midnight. I tried replacing sysdate with current_date but got the same result. In the end though I believe this is close enough for what we're trying to do with the query which is to view a rolling week of COMP workorders, 1 hour doesn't make much difference. Thank you all for your help!



    ------------------------------
    Nathan Frail
    FedEx
    ------------------------------



  • 27.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 11-20-2023 21:34

    I just want to ask the awkward question as you have said "directly", and everyone's assumption is that the attachment is on "the" work order, not its tasks or related inspections.  I ask because each of those have a different OWNERTABLE.



    ------------------------------
    Craig Kokay
    Cosol
    ------------------------------



  • 28.  RE: Generate a list of workorders that contain attachments directly in Maximo

    Posted 11-21-2023 07:40

    In my case, attachments are indeed part of the Workorder, not its tasks or related inspections. I take good note of your comment relating to the different OWNERTABLE.

    Have a nice day!

    Danny



    ------------------------------
    Danny Cordeau
    Universite de Sherbrooke
    ------------------------------