Maximo Anywhere

Expand all | Collapse all

lookup where clause issue

  • 1.  lookup where clause issue

    Posted Mon June 15, 2020 08:23 AM
    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]
    ------------------------------


  • 2.  RE: lookup where clause issue

    Posted Tue June 16, 2020 04:24 AM
    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
    ------------------------------



  • 3.  RE: lookup where clause issue

    Posted Tue June 16, 2020 06:44 AM
    do you have anything explain tho to use  'filterClass' & 'filterMethod' ????




    ------------------------------
    [Abdallah] [Adel]
    [Technical consultant]
    [MegaSoft]
    [Cairo] [Egypt]
    [+201112334228]
    [a_adel@megasoft-arabia.com]
    ------------------------------



  • 4.  RE: lookup where clause issue

    Posted Wed June 17, 2020 01:05 AM
    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
    ------------------------------



  • 5.  RE: lookup where clause issue

    Posted Mon June 22, 2020 01:30 PM
    Of note, Mr. Clark uses the out of the box class "application.handlers.IssuesReturnsHandler".  IBM Best Practice recommendations are to NOT use the out of the box class file, but rather to create a mix-in class and either modify existing or create new method in new file, then in your app.xml make reference to your modified file and method.

    The new class file should be called something similar to  "custom.handlers.xxx_IssuesReturnsHandler" where file is placed in your repository //MaximoAnywhere/apps/{applicationName}/common/js/custom/handlers folder.  This will provide you the ability to avoid custom code overwrite when application is upgraded.  Further the "xxx_" is indicative of client specific naming convention such that you can locate and find client specific modifications easily.

    I trust this 
    helps.

    ------------------------------
    Bradley K. Downing , MBA
    IBM Certified Adv. Deployment Prof. Maximo v7.6.1
    IBM
    Bakersfield CA
    ------------------------------



  • 6.  RE: lookup where clause issue

    Posted Thu August 26, 2021 09:44 AM
    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
    ------------------------------



  • 7.  RE: lookup where clause issue

    Posted Thu August 26, 2021 10:36 AM
    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
    ------------------------------



  • 8.  RE: lookup where clause issue

    Posted Thu August 26, 2021 10:40 AM
    I tried some things but never been able to use the filter.push({}) to get OR on IN

    ------------------------------
    Mathieu Guilmette
    ------------------------------



  • 9.  RE: lookup where clause issue

    Posted Mon August 30, 2021 09:49 AM
    Hi,

    Is there someone who has the correct syntax to use OR or IN operator in the filter.push ?

    Thank you

    ------------------------------
    Mathieu Guilmette
    ------------------------------



  • 10.  RE: lookup where clause issue

    Posted Mon August 30, 2021 10:44 AM
    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
    ------------------------------



  • 11.  RE: lookup where clause issue

    Posted Mon August 30, 2021 11:07 AM
    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
    ------------------------------



  • 12.  RE: lookup where clause issue

    Posted Tue August 31, 2021 05:03 PM
    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
    ------------------------------