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.
Here is the "manually entered" user filter list, which is pre-determined options and values.
I want this to be dynamic, based on the DISTINCT values from the OutcomeStatus column.
The reason? Because if the data changes, I don't have to go into the filter and make changes.
Below is the working filter, but it's NOT dynamic. How do I query the DISTINCT values of the recordType in this expression?
=a!recordFilterList( name: "Status", options: { a!recordFilterListOption( id: 1, name: "In Production", filter: a!queryFilter( field: 'recordType!{793e655d-96f3-490d-9594-62845dbe1ad3}AP Health Application.fields.{8fcf0830-0ea7-4f5a-99a5-b57339b716f0}OutcomeStatus', operator: "=", value: "In Production" ) ), a!recordFilterListOption( id: 2, name: "Decommissioned", filter: a!queryFilter( field: 'recordType!{793e655d-96f3-490d-9594-62845dbe1ad3}AP Health Application.fields.{8fcf0830-0ea7-4f5a-99a5-b57339b716f0}OutcomeStatus', operator: "=", value: "Decommissioned" ) ), a!recordFilterListOption( id: 3, name: "Retired", filter: a!queryFilter( field: 'recordType!{793e655d-96f3-490d-9594-62845dbe1ad3}AP Health Application.fields.{8fcf0830-0ea7-4f5a-99a5-b57339b716f0}OutcomeStatus', operator: "=", value: "Retired" ) ), a!recordFilterListOption( id: 3, name: "Under Evaluation", filter: a!queryFilter( field: 'recordType!{793e655d-96f3-490d-9594-62845dbe1ad3}AP Health Application.fields.{8fcf0830-0ea7-4f5a-99a5-b57339b716f0}OutcomeStatus', operator: "=", value: "Under Evaluation" ) ) }, defaultOption: "", isVisible: true, allowMultipleSelections: true )
If you want distinct value of "OutcomeStatus" you can do grouping which you are already doing it hereI would highly recommend to follow steps from my screenshot.If you still getting duplicate let me know.
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 ) ) ) )