Skip to main content
Known Participant
Mar 22, 2024 7:22 AM UTC
Question

QueryRecordType Count

Hi All,

Can anyone please help me how to get the count of the related record fields from queryRecordType in appian.

    6 replies

    stefanhelzle0001
    Brainy
    Mar 22, 2024 7:43 AM UTC

    I do not understand what exactly you mean with this. Can you help me?

    count of the related record fields
    Known Participant
    Mar 22, 2024 8:34 AM UTC

    In queryrecordtype, there is related record param which get the related record data. My query is to get the count of specific column coming from related record.

    davidj137213
    Brainy
    Mar 22, 2024 8:50 AM UTC

    YOu can get that information from totalCount parameter setting fetchTotalCount =true

    Participating Frequently
    Mar 22, 2024 2:12 PM UTC

    You might be able to achieve this by creating a custom record field getting the count and then using the same for your use case

    mathieud0001
    Genius
    Mar 27, 2024 2:30 AM UTC

    The only way to do this AFAIK is to create a custom record field on the parent record.

    marioo5689
    New Participant
    Mar 26, 2024 6:17 PM UTC

    Hi [mention:9e801b4ea7ba47db8735359b555491e6:e9ed411860ed4f2ba0265705b8793d05]  I don't completely understand whatt are you trying to achieve, but I will give you an answer based on what I understood.

    Example:

    Main record - Vehicle

    Related record - Maintenance

    Output - Total maintenance records related to a single vehicle with vehicle ID "1", you can work with this code to achieve what you may desire

    a!queryRecordType(
      recordType: 'recordType!{99b0bb09-e2c0-4f75-a70b-26f247e2d095}AA Vehicle',
      fields: a!aggregationFields(
        measures: {
          a!measure(
            function: "COUNT",
            field: 'recordType!{99b0bb09-e2c0-4f75-a70b-26f247e2d095}AA Vehicle.relationships.{7f130d4d-d0c7-477e-a98b-41a8119d8411}maintenance.fields.{02dee6e9-599c-4cc6-970a-49dd8d9e7e17}vehicleId',
            alias: "totalMaintenance"
          )
        }
      ),
      filters: a!queryLogicalExpression(
        operator: "AND",
        filters: {
          a!queryFilter(
            field: 'recordType!{99b0bb09-e2c0-4f75-a70b-26f247e2d095}AA Vehicle.fields.{0d5995ff-5e2d-40ad-8ce7-1dc2ebe91919}vehicleId',
            operator: "=",
            value: 1
          )
        },
        ignoreFiltersWithEmptyValues: true
      ),
      pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 100
      )
    ).data