How can I query a table using the display value of an integer field?

Eric Carey2
Kilo Explorer

I am building a filter for a group of tasks in a custom table called u_account_project_tasks. There is a field called "State" in this table that is an integer value with associated display values for the front-end to make it easier for the user to identify in the portal. The filter is a drop-down where the user can select different fields (State, Assignment Group, Category, etc.) and then a search box to type in what State, group, etc. they want to filter for. The line I am struggling with is below:

if (input && input.searchKeyword !=null && input.taskFilterOptions == 'State') {
				task_gr.addQuery('state.getDisplayValue()', "CONTAINS", input.searchKeyword.toString());
    }

 

I want the user to be able to type in the state they want to filter for and then use that value to query the list.

Is there any way to get the display value of the State field inside the query?

1 ACCEPTED SOLUTION

Makes sense, Then Another way would be to first query the choice table to fetch the associated value field.

-Anurag

View solution in original post

3 REPLIES 3

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Cant you add if conditions like 

 

var val = 0;
if(input.searchKeyword.toString() == 'Open')
val = 1;
else if (input.searchKeyword.toString() == 'Closed')
val = 3;

 

 

And at the end pass Val to the GlideRecord Query.

-Anurag

-Anurag

Yes, that is possible and I have thought f it as a backup solution. But there any several states and they could possibly change over time so I do not want to have to continue to add more logic for every possible input. It also does not allow for partial inputs. The user would have to type in the exact state display value to be able to search.

Makes sense, Then Another way would be to first query the choice table to fetch the associated value field.

-Anurag