araisbec
araisbec

Reputation: 1243

IBM Maximo Java API - Cannot filter MboSet by related attribute

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!

Upvotes: 2

Views: 950

Answers (3)

Preacher
Preacher

Reputation: 2145

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'");

Upvotes: -1

JPTremblay
JPTremblay

Reputation: 900

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

Upvotes: 1

araisbec
araisbec

Reputation: 1243

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')");

Upvotes: 3

Related Questions