Hi,
It's me again with another issue regarding filter.
in the WODetailHandler.filterAssetForLookup() , last line is
additionalasset.lookupFilter = filter;
filter is an array that we push value in it like this
filter.push({siteid:siteid});
I would like to know if there is a way to use a
"like".
In my case I want to filter the asset according to a kind of like Hierarchy path.
Here an example of what I would like to have :
wo.customAttribute = "ABC"
asset1.customAttribute = "ABCDEF"
asset2.customAttribute = "ABC"
asset3.customAttribute = "AB"
I would like to see only Asset1 and Asset2 in my list because i want this : select * from asset where customAttribute like 'ABC%'
I don't know how to do this with the
filter[]
and
additionalasset.lookupFilter
Thank you
------------------------------
Mathieu Guilmette
------------------------------
Original Message:
Sent: Tue August 31, 2021 05:03 PM
From: Bradley Downing
Subject: lookup where clause issue
Mathieu,
While I do not know what the rest of your code is doing, it occurs to me that you are not really setting the filter per-se. The filter method you show in your code call-out is blank. What I shared is from an old document that explains how the ModelDataSet.js works with filter input. I know this, if you declare a variable to contain the filter criteria, and then call the filter method on the declared dataset in your custom method, then you can filter that dataset.
The type of filtering that you want to do I think can be found int he WODetailHanlder.js file in the filterLocation method.
filterLocation: function(eventContext){ var workOrderSet = CommonHandler._getAdditionalResource(eventContext,"workOrder"); //save the current location to reset case user cancel //this was done to fix the issue when making a look up and cancel the value in WO detail location was different of showed in the look up this.curLocation = workOrderSet.getCurrentRecord().get("location"); this.curLocationDesc = workOrderSet.getCurrentRecord().get("locationdesc"); this.currLocationld = workOrderSet.getCurrentRecord().get("locationld"); var domainAssetstatus = CommonHandler._getAdditionalResource(eventContext,'domainAssetstatus'); var additionallocations = CommonHandler._getAdditionalResource(eventContext,'additionallocations'); CommonHandler._clearFilterForResource(eventContext,additionallocations); var siteid = CommonHandler._getWorkorderSiteId(eventContext); additionallocations.filter('siteid == $1', siteid); return additionallocations; },
This uses the technique I outlined originally. However, I am not a software engineer so if you want a more technical description you could perhaps open a ticket with support.
------------------------------
Bradley K. Downing , MBA
Solutions Engineer
IBM
Bakersfield CA
Original Message:
Sent: Mon August 30, 2021 11:07 AM
From: Mathieu Guilmette
Subject: lookup where clause issue
Hi Bradley,
My problem is with this kind of filter:
var filter = [];
filter.push({assetnum:assetnum,siteid:siteid});
additionalasset.lookupFilter = filter;
For example, if I want to filter the additionalasset lookup on ASSETTYPE for a specific case (I can't filter the resource in the app.xml for this reason)
if (specificcase){
//I want to this -> worktype in ("type1","type2");
//But can only do this -> filter.push({worktype: worktype});
}
Is there something to do ?
Thank you
------------------------------
Mathieu Guilmette
Original Message:
Sent: Mon August 30, 2021 10:44 AM
From: Bradley Downing
Subject: lookup where clause issue
Mathieu,
Thanks for posting again on this thread. I would have likely pushed your forum request to the back burner and it would have fallen off the stove and fallen behind it to get old and moldy! brouhaha... oh jeez...
So I rummaged through some old files. This is from 2015, so the function should still work, (I have not tested this but it comes from an old reference manual I have.)
ModelDataSet.filter(queryAsString [, listOfParameters])
The method filters the the records that are already loaded in memory, shrinking the list of records the instance exposes. It receive two parameters
-queryAsString = a string with a query to be applied over each record in the data set. Any query that is valid for an "if" statement can be used. Attribute names should be expressed as variables. It also accepts placeholder $1 - $9
-listOfParameters = 0-9 arguments with values to be replaced in the query string in their corresponding placeholder index.
This method returns a reference to the same ModelDataSet instance, so multiple calls to filter() can be chained.
Examples:
modelSet.filter("woNum == '1006' ");
modelSet.filter("woNum == $1", '1006' );
modelSet.filter("woNum == '1006' || status =='COMP' ");
modelSet.filter("woNum == $1 || status == $2 ", '1006', 'COMP' );
modelSet.filter("priority == 1 && creationDate < $1", new Date(2021,8,30));
modelSet.filter("woNum == '1006' || status =='COMP' ").filter(status == 'COMP' "); <=== demonstrates chaining.
As you can see in the case of multiple arguments there is the standard use of the pipe symbol and the ampersand. this implies standard symbolic logic where the pipe ( '|' ) represents "OR" and the ampersand ('&') represents "AND". Of course the double occurrence is the correct code structure so as to not confuse with other code representation using same character. Also in the rewrite of the old manual I am placing spaces in between single and double quotes for readability. Sorry it tok so long to dig this out.
------------------------------
Bradley K. Downing , MBA
Solutions Engineer
IBM
Bakersfield CA
Original Message:
Sent: Mon August 30, 2021 09:49 AM
From: Mathieu Guilmette
Subject: lookup where clause issue
Hi,
Is there someone who has the correct syntax to use OR or IN operator in the filter.push ?
Thank you
------------------------------
Mathieu Guilmette
Original Message:
Sent: Thu August 26, 2021 10:40 AM
From: Mathieu Guilmette
Subject: lookup where clause issue
I tried some things but never been able to use the filter.push({}) to get OR on IN
------------------------------
Mathieu Guilmette
Original Message:
Sent: Thu August 26, 2021 10:36 AM
From: Bradley Downing
Subject: lookup where clause issue
Yes most definitely.... errr.... have to look up the syntax. It has been a while since I have been in my sandbox. Ha!!
------------------------------
Bradley K. Downing , MBA
Solutions Engineer
IBM
Bakersfield CA
Original Message:
Sent: Thu August 26, 2021 09:44 AM
From: Mathieu Guilmette
Subject: lookup where clause issue
Hi,
Your message is very clear and concise ! Thank you for that.
Although, I have an additional question regarding this.
Is there any way to use the operator "OR" in the filter ?
Like if I want to filter the worktype filter and only want to see 4-5 different value, how can I write this using the filter.push ?
Thank you
------------------------------
Mathieu Guilmette
Original Message:
Sent: Wed June 17, 2020 01:05 AM
From: Kasey Clark
Subject: lookup where clause issue
Hi there Abdallah - here's what I generally do in that situation, as an example, we filter the bin to the specific item number in the app.
1. Make sure the resource (additionalbin in my example) has all the value's you'd expect at runtime.
2. Create a lookup of that particular resource, and use a filtermethod on that field:
<lookup filterClass="application.handlers.IssuesReturnsHandler" filterMethod="filterBinForLookup" id="IssuesReturns.BinLookup" label="Select Bin" resource="additionalbin">
3. Then in the method, use the following code to suite your needs:
filterBinForLookup: function (eventContext) {
var additionalbin = eventContext.application.getResource('additionalbin');
var itemnum = eventContext.application.getResource('inventory').getCurrentRecord().itemnum;
var location = eventContext.application.getResource('invreserve').getCurrentRecord().location;
var filter = [];
filter.push({ itemnum: itemnum, location: location });
//filter.push({ location: storeroom });
additionalbin.lookupFilter = filter;
},
------------------------------
Kasey Clark
Original Message:
Sent: Tue June 16, 2020 06:44 AM
From: Abdallah Adel
Subject: lookup where clause issue
do you have anything explain tho to use 'filterClass' & 'filterMethod' ????
------------------------------
[Abdallah] [Adel]
[Technical consultant]
[MegaSoft]
[Cairo] [Egypt]
[+201112334228]
[a_adel@megasoft-arabia.com]
Original Message:
Sent: Tue June 16, 2020 04:23 AM
From: Manikanda Prabhu
Subject: lookup where clause issue
Hi Abdallah
I don't think its possible to define a lookup that changes the values dynamically as we do it in Maximo. You will have to get the entire list of values as a resource and then filter it based on the current record.
You can use the tag 'filterClass' & 'filterMethod' to define your logic.
------------------------------
Manikanda Prabhu
Maximo Solutions Engineer
Deloitte Ireland Maximo CoE
Original Message:
Sent: Mon June 15, 2020 08:22 AM
From: Abdallah Adel
Subject: lookup where clause issue
hello all,
I want to know if there is a guide or a link explaining how to write a correct lookup where clause syntax and I want to know if I can bind a values from the current record in the where clause??
------------------------------
[Abdallah] [Adel]
[Technical consultant]
[MegaSoft]
[Cairo] [Egypt]
[+201112334228]
[a_adel@megasoft-arabia.com]
------------------------------
#MaximoAnywhere
#Maximo
#AssetandFacilitiesManagement