Skip to main content
June 10, 2024
Question

Not able to sum all the value of a field in recordType data

  • June 10, 2024
  • 5 replies
  • 0 views

Hi, I am facing an issue where I want to add all the value of a column and display it on the top of the gridfield, The source of data is a recordType (Adding the code down below), Please help me with this.

{
  a!textField(
    label: "Sum Of Values",
    labelPosition: "JUSTIFIED",
    value: a!currency(isoCode: "USD", value: 0),
    readOnly: true
  ),
  a!gridField(
    labelPosition: "COLLAPSED",
    data: 'recordType!{b43afdfb-93b4-4d94-9708-ffa71f87754a}MWM Test',
    columns: {
      a!gridColumn(
        label: "Value",
        sortField: 'recordType!{b43afdfb-93b4-4d94-9708-ffa71f87754a}MWM Test.fields.{2682c5c7-76eb-4a9a-abf5-d409f2bc3f80}budget',
        value: a!currency(
          isoCode: "USD",
          value: fv!row['recordType!{b43afdfb-93b4-4d94-9708-ffa71f87754a}MWM Test.fields.{2682c5c7-76eb-4a9a-abf5-d409f2bc3f80}budget']
        ),
        align: "CENTER",
        width: "NARROW"
      )
    },
    pageSize: 100,
    selectable: true,
    selectionStyle: "ROW_HIGHLIGHT",
    selectionValue: {},
    selectionSaveInto: {},
    height: "MEDIUM_PLUS",
    showSearchBox: false,
    showExportButton: false,
    showRefreshButton: false
  )
}

    5 replies

    sivanagamalleswarit0001
    Inspiring
    June 10, 2024

    What is the error you are receiving? 

    RecordType can only be used in few components and we cannot pass that data from gridfield.data to text field.

    I would query data into local variable using different functions like queryrecordtype etc.. and pass that as data onto gridfield; as well write sum() on textfield value from this queried data.

    a!localVariables(
      local!data: 
      a!queryRecordType(
        recordType: "tyour record",
        fields: {
      
        },
        pagingInfo: a!pagingInfo(1,50)
      ).data,
      {
        a!textField(
          label: "Sum Of Values",
          labelPosition: "JUSTIFIED",
          value: a!currency(
            isoCode: "USD",
            value: sum(local!data["tyour record",])
          ),
          readOnly: true
        ),
        a!gridField(
          labelPosition: "COLLAPSED",
          data: local!data,
          columns: {
            a!gridColumn(
              label: "Value",
              sortField: "your record",
              value: a!currency(
                isoCode: "USD",
                value: "tyour record", 
              ),
              align: "CENTER",
              width: "NARROW"
            )
          }
        )
      }
    )

    June 11, 2024

    Can we implement userfilter (record filter) in this approach as we have some user filters as well above this grid ?

    sivanagamalleswarit0001
    Inspiring
    June 11, 2024

    we cannot apply userfilters without recorddata

    davidj137213
    Brainy
    June 10, 2024

    Use query Record Type with sum function in order to get the value expected.

    jayaprakashr0001
    Participating Frequently
    June 11, 2024

    Use the sum() for the record data. It will give the expected results.