Skip to main content
October 18, 2024
Question

How can I implement user filter like this

  • October 18, 2024
  • 9 replies
  • 0 views

SELECT * FROM TABLE_A A JOIN TABLE_B B ON A.ID=B.A_ID WHERE B.ROLE IN ('ROLE1','ROLE2') and B.IS_ACTIVE=1

The relationship between A and B is one-to-many, two conditions should be matched in one row

I tried to do

{

queryfilter(Conditon1),

queryfilter(Condition2)

}

But it returned record A with two record B that match one of the conditions each

    9 replies

    kumara0180
    October 18, 2024
    somasundaram.d
    October 18, 2024

    Create a relationship between recordA and recordB as one to many.

    Use the recordB field in the filter

    queryFilter(
    
    field: recordA.relationships.recordB.fields.A_ID,
    
    operator: "IN".
    
    value: {"ROLE1","ROLE2"}
    
    )

    shubhama926776
    Brainy
    October 18, 2024

    If you want to apply filter on TABLE_B would recommend use relatedRecordData

    Have a look at this example:

    https://docs.appian.com/suite/help/24.3/fnc_system_relatedrecorddata.html#only-return-customer-cases-that-have-a-status-of-%22critical%22

    शुभम्
    October 18, 2024

    I tried but this also return record A with emply list record B like following, which make the result count large and reach the paging limit, even if I want to filter the record A with valid record B, I can only filter from the maximum 5000 result

    shubhama926776
    Brainy
    October 18, 2024

    May be condition does not match for id:16.
    Can you validate that?
    Looks like for id:17 it worked.

    शुभम्
    October 18, 2024

    You can can try in the following way:

    a!queryRecordType(
      recordType: recordType!A,
      fields: {},
      filters: a!queryLogicalExpression(
        operator: "AND",
        filters: {
          a!queryFilter(
            field: recordType!A.relationships.B.fields.city,
            operator: "in",
    		value: {"New York", "Chicago"}
          ),
          a!queryFilter(
            field: recordType!A.relationships.B.fields.isActive',
            operator: "=",
            value: true
          )
        }
      ),
      pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 100
      )
    ).data

    prasantap0900
    October 21, 2024

    You can use a!queryLogicalExpression()