I have an endpoint which returns data consists of 5 columns (text and date fields). I want to keep an text field and then when I enter values in the text field, I want to filter the data based on the value I entered.
It should filter dates if possible
Discussion posts and replies are publicly visible
OK ... but what is your question?
data comes from the endpoint, I will keep a text filed in the interface and I call the endpoint in the interface and display it in a grid form.
When I enter some value in text field, I want to filter the grid
Need to know how data is structured and end point is configured . You can either filter the data directly from endpoint by passing path parameters or query parameters or you load all the data onto interface and you can use index and where contains to filter data
We need more details, existing code snippets, data structures! Us, just guessing, will not be able to help you forward.
local!search,
local!data: [
{
name: Vijay,
dob:10/01/2001,
address: "near 4th Busstop"
},
name: Pavan,
dob:11/11/2011,
address: "near KFC"
name: Mohaseen,
address: "near Church street"
}
],
local!griddata: if(
a!isNullOrEmpty(local!search),
local!data,
query(local!data),
)
so, I used local!griddata in a read only grid, and I took a text field above the grid and gave local!search as its value.
So if I enter 'C' in the text field, then I need to show only 2nd and 1st items from the local!data local variable as Pavan's and Mohaseen's address contains character 'C'
a!localVariables( local!search: "KFC", local!data: { { name: "Vijay", dob: 10/01/2001, address: "near 4th Busstop" }, { name: "Pavan", dob: 11/11/2011, address: "near KFC" }, { name: "Mohaseen", dob: 11/11/2011, address: "near Church street" } }, index( local!data, where(like(lower(local!data.address), lower("*" & local!search & "*"))), null ) )
like() with the asterisk checks whether a string matches that pattern and supports lists
where() returns the indexes of true values in a list of booleans
here the search variable is only checking address, I want to use search variable to check address and name too.
Suppose if the first person name is Christina, I want to get that as well
Then , you can use the filter function and an additional expression that checks the conditions for a single item.
https://docs.appian.com/suite/help/24.4/fnc_looping_filter.html