2

This question pertains to the Java API of Maximo Asset Management.

To meet a business requirement, I must filter an MboSet by an attribute of a related object; to be specific, I need to filter a WORKORDER set such that only WO's with LOCATIONS containing a certain attribute value are selected (a custom attribute).

Using the "SetWhere" function, I am unable to filter an MboSet by a related attribute using the syntax "LOCATION.ATTRIBUTE_NAME = 'VALUE'"... I swear I was able to do this using SetQBE. How can I do this using SetWhere?

Is there a better way? I don't want to store this value in the WORKORDER object and duplicate data. Thank you!

araisbec
  • 1,223
  • 3
  • 16
  • 27

3 Answers3

2

Nevermind everyone... the answer (after failing to find one online) was simple, and uncovered through trial and error.

Suppose you want to filter a WORKORDER MboSet by an attribute belonging to a related object (in my case, a custom attribute on the LOCATIONS object). Logically, this is what you want to accomplish:

remoteMboSet.setWhere("LOCATION.CUSTOM_ATTRIB = 'VALUE'");

...to get the actual behavior and result, your syntax is as follows:

remoteMboSet.setWhere("LOCATION IN (SELECT LOCATION FROM LOCATIONS WHERE CUSTOM_ATTRIB = 'VALUE')");
araisbec
  • 1,223
  • 3
  • 16
  • 27
  • 1
    Don't forget about a siteid filter, though if this is meant for a specific company, it might not matter. The "setWhere" clause is literally setting the "where" clause of an SQL statement. The xyz in "select * from where xyz", so if it doesn't make sense / can't run in a query tool like that, then it won't work in that method call either. A "setQBE" on the other hand (as JPTremblay suggests) uses more of the business logic so you can actually use their dot notation. It also comes with more overhead, but that likely isn't a problem.
    – Dex Dec 04 '19 at 02:01
  • The "Logically, this is what you want to accomplish" bit should be worked into your Question to improve the quality of your Question. – Preacher Dec 04 '19 at 15:32
1

Yes, you can use the dot notation with the QBE API to have filtering based on related objects.

This should work:

remoteMboSet.setQbe("RELATION.ATTRIBUTE", "='VALUE'");

This is in fact how the new REST API works internally. https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html#_filtering_data_using_where_clause

JPTremblay
  • 900
  • 5
  • 8
0

In your own answer to your question, you said:

Logically, this is what you want to accomplish

remoteMboSet.setWhere("LOCATION.CUSTOM_ATTRIB = 'VALUE'");

What you are missing from that line is a colon : on the front of LOCATION. That's right: you can use bind variables in your where clause sent to setWhere(). Here's the quoted code adjusted:

remoteMboSet.setWhere(":LOCATION.CUSTOM_ATTRIB = 'VALUE'");
Preacher
  • 2,127
  • 1
  • 11
  • 25