Skip to main content
September 21, 2022
Question

How to get top 3 documents list

  • September 21, 2022
  • 2 replies
  • 0 views

I have a requirement to get the top 3 documents list which are larger in size in a KC.

I was a able to get the complete list with getfileslargerthansize() but doesn't know how to get top 3 documents onlly.

Can anyone please help. Thanks in Advance

    2 replies

    stefanhelzle0001
    Brainy
    September 21, 2022

    Create a list of maps with two fields each. The document and the size. Then use todatasubset to sort by size and set the batch size to 3.

    Participating Frequently
    September 21, 2022

    Check the below code.

    a!localVariables(
    
      local!xyz:a!forEach(
    
        items: getfileslargerthansize(
    
          tofolder(131788),/*knowledge center*/
    
          2000000/*document size*/
    
        ),
    
        expression: {
    
          size:document(
    
            fv!item,"size"
    
          ),
    
          name:fv!item
    
        }
    
      ),
    
      index(local!xyz,wherecontains(
    
        index(
        /*I have used the sort plugin here */
          sortintegerarray(
    
          local!xyz.size,
    
          true()
    
        ),enumerate(3)+1,{}),
    
        tointeger(index(local!xyz,"size",{}))
    
      ),{}),
    
     
    
    )