I am trying to create a user filter with the results from an expression rule which displays distinct options from my table.
I have researched the documentation, and was unable to find any answers with an example.
How do I call the expression rule to populate the options for this user filter based on the results from the expression rule I have created?
Many thanks in advance for your assistance.
Discussion posts and replies are publicly visible
Hello Scott Fleming You have to use a!recordFilterList().This documentation explain with example.
I already followed the instructions from the link, however I do not know how to write the a!recordFilterList() function to obtain the DISTINCT values of a field.
The documentation does not display an example code to write.
I created an expression rule, that queries distinct values from "Outcome Status" field, and want it to be the options for the user filter.
Scott Fleming I have attach my sample code for your reference.Try to replicate my code for your requirement. Keep me posted if you have any questions.
Invalid Parameter warnings.
.
Your AP_Outcome_Status rule is correct only you have to remove .dataandI have replicate your code.Try this and let me know.
a!recordFilterList( name: "OutcomeStatus", options: a!forEach( items: rule!AP_Outcome_Status(), expression: a!recordFilterListOption( id: fv!index, name: fv!item.OutcomeStatus, filter: a!queryFilter( field:'recordType!{793e655d-96f3-490d-9594-62845dbe1ad3}.fields.{8fcf0830-0ea7-4f5a-99a5-b57339b716f0}', operator: "=", value: fv!item.OutcomeStatus ) ) ) )
This is where I get lost. You're using an expression rule which is a pre-defined query of the data, but the grouping section accesses the field of the recordType, not the output of the expression rule.
a!localVariables( local!category: rule!WAR_QR_getDeficiencyCode( fields: a!affregationFields( groupings: { a!grouping( field: "WAR_Defiency code.category" <--- Isn't this from your record Type?
Correct try above my implementation. Let me know
I applied the code for the user filter expression you provided above, which seems to be the exact code used to create the expression rule???
In any case... here's the error.
You have to replace record from line no. 9 to
a!recordFilterList( name: "OutcomeStatus", options: a!forEach( items: rule!AP_Outcome_Status(), expression: a!recordFilterListOption( id: fv!index, name: fv!item.OutcomeStatus_grouping1, filter: a!queryFilter( field: /*"Replace record here"*/, operator: "=", value: fv!item.OutcomeStatus_grouping1 ) ) ) )
Ok. Things are getting clearer.
This is my expression rule, to obtain distinct values from "OutcomeStatus" column:
Next, my user filter, which I see access the "alias" from my rule, but the rule output does not have an index.
So, the user filter is expecting an fv!index and there is none
I get no errors, but the filter displays no values.