cancel
Showing results for 
Search instead for 
Did you mean: 

How to search for only one property in Object Table offline in MDK

dwipal
Explorer
0 Kudos
953

I have enabled the search property to TRUE and as its behaviour, it is going to search for all the properties that are binded in the table. So how to make it work for only one property. 

View Entire Topic
Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert

@dwipal Please use this snippet for your rule

 

export default function SearchCustomerListName(context) {
let pageProxy = context.getPageProxy();
console.log("pageProxy",pageProxy)
let search = context.searchString;
console.log("search",search)
let qoB = context.dataQueryBuilder();
console.log("qoB",qoB);
if(search && search != ''){
let productname = qoB.filterTerm(`substringof(tolower('${search}'),tolower(Name1))`);
console.log("productname",productname);
qoB.filter(productname);
return qoB;
}
}
dwipal
Explorer
0 Kudos

Hello @Jitendra_Kansal, Thanks for the above approach. It worked but when i am adding additional query it did not working as earlier. So basically I get the customers based on the product associated with the customers and after that i search the customer name, so initially for empty search string it is working fine. it only fetch those customer which are equal to the given productId. But when i start searching for name it search from all the data list instead of those customer that are equal to the productId only.

  let pageClientData =context.binding;
    let productId = pageClientData.productId;

    // Simple value assignment.
    let search = context.searchString;
    let qoB = context.dataQueryBuilder();

  if (!search) {
        let productFilter = qoB.filterTerm(`ProductId eq '${productId}'`);
       
        qoB.filter(productFilter);
        
  }
    console.log("qoB",qoB);
    if(search && search != ''){
        let username = qoB.filterTerm(`substringof(tolower('${search}'),tolower(Name))`);
        let productFilterTest = qoB.filterTerm(`ProductId eq '${productId}'`);

        qob.filter().and(productFilterTest,username);

    }
    return qoB;

 

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos
Could you share how do you get Customers based on the product on the page?
dwipal
Explorer
0 Kudos

Hello @Jitendra_Kansal, The issue regarding productID is also resolved. Thanks for your suggestions and help

 let pageClientData =context.binding;
    let productId = pageClientData.productId;

    // Simple value assignment.
    let search = context.searchString;
    let qoB = context.dataQueryBuilder();
  let appFilter =`ProductId eq '${productId}'`;
    if (!search) {
       qoB.filter(appFilter);      
    }

    if(search && search != ''){
        let username = qoB.filterTerm(`substringof(tolower('${search}'),tolower(Name))`);
       
        qoB.filter(appFilter).and(username);

    }
    return qoB;