Search Feature in Grid not working for One is to Many Relationship

Certified Senior Developer

I have Room (roomID column) and a Key (with keyID, roomID, and keyDescription columns) . A room can have multiple keys. I setup a one to many relationship between the Room and a Key using the roomID. 

I used the Room record to populate a gridField. The search is not returning anything if I put an information that should match the keyDescription. I have the code below. I am only after for keys that are active which is one active key per room. Even if I remove the filter in the code, it does not return anything. Is this expected for a One to Many relationship? 

 

{
a!gridField(
data: a!recordData(
recordType: <room_record>,
relatedRecordData: a!relatedRecordData(relationship: '<roomRecord-keyRecord>',
filters: {
a!queryFilter(
field: '<keyRecord.isActive>',
operator: "=",
value: true
)
}
),
columns: {

a!gridColumn(
label: "Room ID",
sortField: 'roomRecord.roomID',
value: fv!row['roomRecord.roomID'],
),

a!gridColumn(
label: "Key Description",
sortField: 'roomRecord-keyRecord.keyDescription',
value: fv!row['roomRecord-keyRecord.keyDescription'],
)
)
}

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi Vernon,

    In the query filter can you try putting values like below


    a!queryFilter(
    field: '<roomRecord.relationships.keyRecord.isActive>',
    operator: "=",
    value: true
    )
    This is working for me

    and if you want only specific related record data, please pass filters in 

    relatedRecordData: a!relatedRecordData(relationship: '<roomRecord-keyRecord>', filters:queryFilter())

    Hope this helps

  • 0
    Certified Senior Developer
    in reply to virat yogi

    Thanks Virat. I dont have a problem with the query. My problem is with the search.

    Your suggestion will generate an error. As documented in , it should be done this way

      relatedRecordData: {

      /*Only return related Employees that have a status of active*/

       a!relatedRecordData(

       relationship: recordType!Department.relationships.employee,

        filters: {

           a!queryFilter(

            field: recordType!Employee.fields.status,

             operator: "=",

             value: "Active"

             )

           }

         )

       }

Reply
  • 0
    Certified Senior Developer
    in reply to virat yogi

    Thanks Virat. I dont have a problem with the query. My problem is with the search.

    Your suggestion will generate an error. As documented in , it should be done this way

      relatedRecordData: {

      /*Only return related Employees that have a status of active*/

       a!relatedRecordData(

       relationship: recordType!Department.relationships.employee,

        filters: {

           a!queryFilter(

            field: recordType!Employee.fields.status,

             operator: "=",

             value: "Active"

             )

           }

         )

       }

Children