Getting data group by field and the latest one

Certified Lead Developer

Hi Champs,

I need to fetch only unique value from a dictionary with the latest data. Below is the sample of the output

Here you can see color highlighted ones are same value of training name. So instead of 5 dictionary I want only 3 with unique training name . For unique data I want to fetch the latest of duplicate data.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hello  

    I hope this is what you have asked. (Sorry for the old reply. Didn't catch the last part)

    a!localVariables(
      local!data: a!queryRecordType(
        recordType: 'recordType!{813c8d12-c70d-4373-b9d3-bbb60dbb1d56}Employee Detail',
        fields: {},
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 100)
      ).data,
      /*Replace with your rule*/
      local!lastName: a!map(
        lastName: index(
          local!data,
          'recordType!{813c8d12-c70d-4373-b9d3-bbb60dbb1d56}Employee Detail.fields.{c9452bf3-7a5b-4464-bdea-a86ec4c64484}lastname',
          null
        ),
        id: index(
          local!data,
          'recordType!{813c8d12-c70d-4373-b9d3-bbb60dbb1d56}Employee Detail.fields.{a79c1c0e-7077-44ca-85f6-de6f4b0d969c}id',
          null
        ),
        
      ),
      /*Replace the record and reference type*/
      local!uniqueLastName: union(
        local!lastName.lastName,
        local!lastName.lastName
      ),
      local!latestIds: a!flatten(
        a!forEach(
          items: local!uniqueLastName,
          expression: {
            max(
              index(
                local!lastName.id,
                wherecontains(
                  tostring(fv!item),
                  touniformstring(local!lastName.lastName)
                ),
                null
              )
            )
          }
        )
      ),
      a!forEach(
        items: local!latestIds,
        expression: index(
          local!data,
          wherecontains(
            tointeger(fv!item),
            tointeger(
              index(
                local!data,
                'recordType!{813c8d12-c70d-4373-b9d3-bbb60dbb1d56}Employee Detail.fields.{a79c1c0e-7077-44ca-85f6-de6f4b0d969c}id',
                null
              )
            )
          ),
          null
        )
      )
    )
    /*Tried out in my apprach a better and efficient way might also be available. Till then this might do the job*/


    Please update the data and the indexes to work according to your data.

Reply
  • 0
    Certified Senior Developer

    Hello  

    I hope this is what you have asked. (Sorry for the old reply. Didn't catch the last part)

    a!localVariables(
      local!data: a!queryRecordType(
        recordType: 'recordType!{813c8d12-c70d-4373-b9d3-bbb60dbb1d56}Employee Detail',
        fields: {},
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 100)
      ).data,
      /*Replace with your rule*/
      local!lastName: a!map(
        lastName: index(
          local!data,
          'recordType!{813c8d12-c70d-4373-b9d3-bbb60dbb1d56}Employee Detail.fields.{c9452bf3-7a5b-4464-bdea-a86ec4c64484}lastname',
          null
        ),
        id: index(
          local!data,
          'recordType!{813c8d12-c70d-4373-b9d3-bbb60dbb1d56}Employee Detail.fields.{a79c1c0e-7077-44ca-85f6-de6f4b0d969c}id',
          null
        ),
        
      ),
      /*Replace the record and reference type*/
      local!uniqueLastName: union(
        local!lastName.lastName,
        local!lastName.lastName
      ),
      local!latestIds: a!flatten(
        a!forEach(
          items: local!uniqueLastName,
          expression: {
            max(
              index(
                local!lastName.id,
                wherecontains(
                  tostring(fv!item),
                  touniformstring(local!lastName.lastName)
                ),
                null
              )
            )
          }
        )
      ),
      a!forEach(
        items: local!latestIds,
        expression: index(
          local!data,
          wherecontains(
            tointeger(fv!item),
            tointeger(
              index(
                local!data,
                'recordType!{813c8d12-c70d-4373-b9d3-bbb60dbb1d56}Employee Detail.fields.{a79c1c0e-7077-44ca-85f6-de6f4b0d969c}id',
                null
              )
            )
          ),
          null
        )
      )
    )
    /*Tried out in my apprach a better and efficient way might also be available. Till then this might do the job*/


    Please update the data and the indexes to work according to your data.

Children
No Data