Skip to main content
March 22, 2024
Question

QueryRecordType Count

  • March 22, 2024
  • 6 replies
  • 0 views

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
    March 22, 2024

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

    count of the related record fields
    March 22, 2024

    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
    March 22, 2024

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

    March 22, 2024

    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
    Brainy
    March 27, 2024

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

    marioo5689
    March 26, 2024

    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