How to get top 3 documents list

Certified Associate Developer

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

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    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",{}))
    
      ),{}),
    
     
    
    )

Reply
  • 0
    Certified Lead Developer

    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",{}))
    
      ),{}),
    
     
    
    )

Children
No Data