4

In the WOTRACK app of Maximo, I need to find some way to programmatically access the where clause of the current window query. It's clear this exists somewhere in Maximo, since you can access it in the UI under Advanced Search > Where Clause. I need to find some way to get this info programmatically and pass it on to an application I am working with.

In the past I've hacked together a way of grabbing this data by having the user open the where clause window in Maximo, and then just retrieving the value of the textarea element containing the where clause. I'm hoping to find some way to access it through Maximo's Java classes, so the user doesn't have to open that window. I've dug through Maximo's Javadocs and I can see there is a WhereClauseTextArea class which I believe would be responsible for creating the text area. I would like to be able to pass the UI session ID to Maximo's Java classes and get back the current where clause for the list. Is there a simple way of doing this? I would like to be able to use JavaScript to access this from the front end, or Java to access it from the back end of Maximo, or an automation script as a last resort.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Jesse Williams
  • 140
  • 1
  • 8
  • This related post might be of interest: [New java classes & methods in 7.6.1.2?](https://community.ibm.com/community/user/iot/communities/community-home/digestviewer/viewthread?GroupId=727&MessageKey=4a092ffa-5816-4380-9b81-165f960fe3f1&CommunityKey=3d7261ae-48f7-481d-b675-a40eb407e0fd&tab=digestviewer). – User1974 May 08 '21 at 02:40

2 Answers2

6

In Maximo 7.6.1.1/Jython, we can use the getWebClientSession() method:

wclause = service.webclientsession().getCurrentApp().getResultsBean().getMboSet().getUserAndQbeWhere() 

service.error("The WHERE clause is : ", wclause);
User1974
  • 276
  • 1
  • 17
  • 63
  • 2
    I am surprised IBM is enhancing (or creating and using) a "psdi" package class for this, instead of their service context or something new in the "ibm" package. – Dex Oct 22 '19 at 13:27
  • Do you know why I would be getting this error when trying to access the mbo set: "AttributeError: 'psdi.common.context.UIContext' object has no attribute 'getWebClientSession'" – Quinn Apr 22 '20 at 17:13
  • 1
    @Quinn You could try asking a separate question about it here or on the [Maximo Community page](https://community.ibm.com/community/user/communities/community-home/digestviewer?communitykey=3d7261ae-48f7-481d-b675-a40eb407e0fd&tab=digestviewer). – User1974 Apr 22 '20 at 17:26
  • The import of UIContext isn't needed, as UIContext is never directly referenced. – Preacher Aug 28 '20 at 15:29
  • @Preacher Thanks. I removed it from the answer. – User1974 Aug 28 '20 at 16:45
  • Your credit link to AndreasBr has died, thanks to IBM moving the developerWorks forum. The Wayback Machine doesn't seem to have it, but do you happen to have saved a copy or anything of the original text? – Mast Feb 03 '23 at 17:01
  • 1
    No, but I remember the info in that post being limited. I think you'd find much better information by searching for things like "webclientsession" on the [IBM Maximo Community page](https://community.ibm.com/community/user/communities/community-home?CommunityKey=3d7261ae-48f7-481d-b675-a40eb407e0fd). Such as this post of mine: [It works! Access the UI via an automation script (using getWebClientSession)](https://community.ibm.com/community/user/communities/community-home/digestviewer/viewthread?GroupId=727&MessageKey=72fedf74-7167-42aa-af41-2e79b70dc7b7). – User1974 Feb 03 '23 at 18:01
  • 1
    ...Or go to Bruno Portaluri (MaximoDev)'s [Accessing UI methods from automation scripts](https://bportaluri.com/2022/12/accessing-ui-methods-from-automation-scripts.html). Or just google "WebClientSession" or something similar. Note: I don't work in the Maximo industry anymore, so am out of the loop. – User1974 Feb 03 '23 at 18:03
3

Maximo has a number of different where clause sources (app restrictions, object restrictions, relationships, QBE (Query By Example) filters, site restrictions, and more). With an Automation Script (Python or JavaScript), you should be able to snag what you're looking for from mbo.getThisMboSet().getUserWhere() or .getUserAndQbeWhere() or .getWhere(). As a commenter pointed out, .getCompleteWhere() may also be helpful.

You can find the JavaDocs on those psdi.mbo.MboSet methods, or find other "where clause getting" methods, here.

Preacher
  • 2,127
  • 1
  • 11
  • 25
  • 1
    Depending on how much of the where clause he or she wants, and wants to piece together, there is also the `.getAppWhere()`. The `.getCompleteWhere()` will get all of those pieced/layered together, which I believe is what you actually see in the "where clause" search dialog. – Dex Jun 22 '19 at 03:41
  • I've tried `mbo.getThisMboSet.getUserWhere()` and `getUserAndQbeWhere()`. `getUserWhere` gives me an empty string, and `getUserAndQbeWhere` gives me a where clause like `(workorderid = 2)`, which is not what I need, since that refers only to that single mbo. I want the where clause for the entire list window. @Dex, I've been looking into your suggestion, do I need to access the WebClientSession to get access to those methods? It looks like they would be on one of the beans in the WebClientSession... How can I access those methods? – Jesse Williams Jun 24 '19 at 17:11
  • @Jesse All those methods (`getUserWhere()`, `geUserAndQbeWhere()`, `getCompleteWhere()`, and etc) are on `psdi.mbo.MboSet`, which you get an instance of from `mbo.getThisMboSet()` in your automation script. Follow the link to the documentation I provided in my answer, click the `psdi.mbo` package in the top left frame, then click the `MboSet` class in the bottom left frame, then use your browser to search for `Where` to find all the methods for getting the different parts of the Where clause in effect for this MboSet. – Preacher Jun 24 '19 at 18:12
  • 3
    OK, right. My issue with accessing through an mbo in an automation script is that the `MboSet` attached to the mbo I am working with has only the one mbo, not the whole list from the list tab in Maximo, and I don't know why that is. I've actually solved the issue by accessing the `WebClientSession` and calling `wcs.getCurrentApp().getResultsBean().getMboSet().getUserAndQbeWhere()`. This gives me the `MboSet` contained in the list tab, which I then get the where clause from. Thanks for the help! – Jesse Williams Jun 24 '19 at 19:58
  • 1
    Ah yes, the results bean does control the list screen separately from the rest of the app. I remember dealing with that 7 or 8 years ago, now that you mention it. Since automation scripts have come along, most people dislike using Java customizations, which means no access to the bean classes, so stuff like this gets forgotten about. Sorry. – Dex Jun 25 '19 at 01:20
  • @Jesse, this sounds like a good case for raising a [Request For Enhancement (RFE)](https://www.ibm.com/developerworks/rfe/execute?use_case=viewRFEs) – Preacher Jun 25 '19 at 14:00