User Filter Duplicates?

Certified Senior Developer

Hi all,

I'm creating user filters for a variety of fields in a record-backed read-only grid. How do I make it so duplicates don't show up in the user-filter drop down list? 

For example, if you want to filter by status, there are two statuses available for all the records: Forecasted and Posted. How do I get it to just display Posted and Forecasted once, and not for as many times as there are records? I've tried union() on the 'name' parameter of the a!recordFilterListOption() function but that didn't work. Thanks for any suggestions!

  Discussion posts and replies are publicly visible

Parents
  • If you pass the same array into union twice, it should filter out the duplicates.  Here's the docs for union that show an example.  If that doesn't work, can you post the code you tried?

    docs.appian.com/.../fnc_set_union.html

  • 0
    Certified Senior Developer
    in reply to Josh Bright

    a!localVariables(
      local!values: a!queryRecordType(
        recordType: 'recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity',
        fields: {
          'recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{d09292ab-4af5-43e5-b54a-10499bb3e945}status',
          'recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{09319a39-6153-41c1-8228-2dde7ba38ccd}opportunityId'
        },
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: cons!GMS_QUERY_RECORD_MAXIMUM_BATCH_SIZE,
          sort: a!sortInfo(
            field: 'recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{09319a39-6153-41c1-8228-2dde7ba38ccd}opportunityId',
            ascending: true
          )
        ),
        filters: {}
      ).data,
      
      a!recordFilterList(
        name: "Status",
        options: a!forEach(
          items: union(local!values, local!values),
          expression: a!recordFilterListOption(
            id: fv!item['recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{09319a39-6153-41c1-8228-2dde7ba38ccd}opportunityId'],
            name: fv!item['recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{d09292ab-4af5-43e5-b54a-10499bb3e945}status'],
            filter: a!queryFilter(
              field: 'recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{09319a39-6153-41c1-8228-2dde7ba38ccd}opportunityId',
              operator: "=",
              value: fv!item['recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{09319a39-6153-41c1-8228-2dde7ba38ccd}opportunityId']
            )
          )
        ),
        defaultOption: null,
        isVisible: true,
        allowMultipleSelections: true
      )
    )

    I did try union on the items: parameter of the forEach loop. Is that not the correct place? I've tried it elsewhere as well, but doesn't appear to be working. My user filter list still looks like this:

  • So when you are doing the union, its making a unique list of items, but its looking at both the status and opportunityId to do that.  Since each of the statuses has a unique opportunityId, its keeping all the items in the list.  What you want to be doing is just looking at the status field and using that to make the unique list.

    Give this a shot:

    a!localVariables(
      local!values: a!queryRecordType(
        recordType: 'recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity',
        fields: {
          'recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{d09292ab-4af5-43e5-b54a-10499bb3e945}status',
        },
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: cons!GMS_QUERY_RECORD_MAXIMUM_BATCH_SIZE,
          sort: a!sortInfo(
            field: 'recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{09319a39-6153-41c1-8228-2dde7ba38ccd}opportunityId',
            ascending: true
          )
        ),
        filters: {}
      ).data[recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{d09292ab-4af5-43e5-b54a-10499bb3e945}status],
      union(local!values, local!values)
    )

    I didn't include the recordFilterList part, but, the output of that should be a unique list of statuses.  From there you should be able to do the dropdown list.  I'm a bit new to Appian still, so I'm not sure exactly how to do that part, but I'd imagine you can use the status name as the id and the name in the dropdown, as I think you are really wanting to do a filter by the status name, and not the opportunity id?

Reply
  • So when you are doing the union, its making a unique list of items, but its looking at both the status and opportunityId to do that.  Since each of the statuses has a unique opportunityId, its keeping all the items in the list.  What you want to be doing is just looking at the status field and using that to make the unique list.

    Give this a shot:

    a!localVariables(
      local!values: a!queryRecordType(
        recordType: 'recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity',
        fields: {
          'recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{d09292ab-4af5-43e5-b54a-10499bb3e945}status',
        },
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: cons!GMS_QUERY_RECORD_MAXIMUM_BATCH_SIZE,
          sort: a!sortInfo(
            field: 'recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{09319a39-6153-41c1-8228-2dde7ba38ccd}opportunityId',
            ascending: true
          )
        ),
        filters: {}
      ).data[recordType!{872b7ffe-4d94-4ffe-8cc9-e9d180175c65}GMS Opportunity.fields.{d09292ab-4af5-43e5-b54a-10499bb3e945}status],
      union(local!values, local!values)
    )

    I didn't include the recordFilterList part, but, the output of that should be a unique list of statuses.  From there you should be able to do the dropdown list.  I'm a bit new to Appian still, so I'm not sure exactly how to do that part, but I'd imagine you can use the status name as the id and the name in the dropdown, as I think you are really wanting to do a filter by the status name, and not the opportunity id?

Children
No Data