Skip to main content
December 28, 2022
Solved

I am not getting all the records for a record type relationship

  • December 28, 2022
  • 7 replies
  • 0 views

I have a Class record type and a Student Record type with a relationship between them one-to-many.

when I try to get a Class with all the students (every student contains classId) I get only 10 of them but I have much more.

how can I fix it? 

a!queryRecordType(
  recordType: 'Class',
  fields: {
    'Class.relationships.Student'
  },
  filters: a!queryLogicalExpression(
    operator: "AND",
    filters: {
      a!queryFilter(
        field: 'Class.Id',
        operator: "=",
        value: ri!id
      )
    },
    ignoreFiltersWithEmptyValues: true
  ),
  pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 100
  )
).data[1]

Best answer by harshitham3563

Hi, We can get max of 10 related record data and if we need more we need to query them separately.

7 replies

alexandru.boerescu
December 28, 2022

Could you double check to see if the student record has been synced? Also check to see if for that specific class.id you have more than 10 students.

amitf1507Author
December 29, 2022

yes I checked

December 28, 2022

I think you are trying to relate the record whose source is a view(in Entity backed record), we can't get advanced features options when we are using View a source (features like record relations , record sync's are not possible )

December 29, 2022

Hi, We can get max of 10 related record data and if we need more we need to query them separately.

jorgez0002
March 24, 2023

Obviously will be a hit to performance but you can get around it w/ an update() and a second query. 

Took some guesses with the data structure but maybe something like this:

a!localVariables(
  local!class: a!queryRecordType(
    recordType: 'Class',
    fields: { 'Class.relationships.Student' },
    filters: a!queryLogicalExpression(
      operator: "AND",
      filters: {
        a!queryFilter(
          field: 'Class.Id',
          operator: "=",
          value: ri!id
        )
      },
      ignoreFiltersWithEmptyValues: true
    ),
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 100)
  ),
  local!student: rule!TMP_queryStudent(classId: fv!item['Class.Id']).data,
  todatasubset(
    a!forEach(
      items: local!class.data,
      expression: a!update(
        fv!item,
        'Class.relationships.Student',
        index(
          local!student,
          wherecontains(
            ri!id,
            tointeger(local!student['Student.ClassId'])
          ),
          null
        )
      )
    )
  )
)

stefanhelzle0001
Brainy
March 24, 2023

While this technically works, I highly suggest to use a!localVariables() instead of with() and NOT to query data in a loop. Try to fetch the required items in one go and remap them in a second step.

jorgez0002
March 24, 2023

You're right, updated the code mockup.