Get a list of all Knowledge Centers' names and sizes

A Score Level 1

Hi all,

We're running out of disk space on our cloud environment. Appian Support has identified that the main culprits are our Knowledge Centers. They can't however identify which specific Knowledge Centers are the largest. We have over a hundred though so it may just be an accumulation of them all.

But anyway, I need to find all their individual sizes and am hoping someone knows how to do this without manually checking each Knowledge Center's properties?

An option I'm trying is: 

a!localVariables(
  local!knowledgeCenter: cons!ABC_KNOWLEDGE_CENTER_PROPERTIES,
  a!forEach(
    items: local!knowledgeCenter,
    expression: {
      creator: knowledgecenter(fv!item, "creator"),
      dateCreated: knowledgecenter(fv!item, "dateCreated"),
      description: knowledgecenter(fv!item, "description"),
      id: knowledgecenter(fv!item, "id"),
      name: knowledgecenter(fv!item, "name"),
      numberOfDocuments: knowledgecenter(fv!item, "numberOfDocuments"),
      size: knowledgecenter(fv!item, "size") / 1000000 & " MB"
    }
  )
)

Which outputs a useful list like this:

  • Dictionary
      • creator"john.wayne@domain.com"(Text)
          • dateCreated28/11/2022 12:44 GMT+02:00(Date and Time)
              • description"Folder for knowledge center"(Text)
                  • id185543(Number (Integer))
                      • name"UVW Knowledge Center"(Text)
                          • numberOfDocuments 50(Number (Integer))
                              • size "10.95459 MB"(Text)
                                    • creator"john.wayne@domain.com"(Text)
                                        • dateCreated10/07/2022 13:47 GMT+02:00(Date and Time)
                                            • description"Folder for knowledge center"(Text)
                                                • id1679445(Number (Integer))
                                                    • name"XYZ Knowledge Center"(Text)
                                                        • numberOfDocuments 38(Number (Integer))
                                                            • size "8.979983 MB"(Text)

                                                          Thing is, the Constant I'm using in the expression... I need to manually add each Knowledge Center to that Constant which also seems like a long way round:

                                                          Does anybody please have a simpler way to get a list of all Knowledge Centers and their sizes?

                                                          Many thanks,
                                                          Uel

                                                            Discussion posts and replies are publicly visible

                                                          Parents
                                                          • It's not pretty and it is clunky but you can navigate to the "All Objects" view, filter by Folder and Search using "Knowledge Center" (assuming your KCs are all named this way):

                                                            You can then open the properties of each to get the contents/size value.

                                                          • 0
                                                            A Score Level 1
                                                            in reply to Stewart Burchell

                                                            Thanks Stewart. Are there any plans in place to display folder sizes in an easier-to-view method? 

                                                          • 0
                                                            Appian Employee
                                                            in reply to Uel_M

                                                            Sorry, I know of no such plans. In the meantime here's something I've cooked up. It relies on the Content Tools plug-in from the App Market:

                                                            a!localVariables(
                                                              local!ids: fn!enumerate(2000) + 1300,
                                                              local!contentObjects: a!forEach(
                                                                items: local!ids,
                                                                expression: fn!getcontentobjectdetailsbyid(fv!item)
                                                              ),
                                                              local!potentialKCs: a!forEach(
                                                                items: local!contentObjects,
                                                                expression: if(
                                                                  fv!item = "No object with this ID has been found",
                                                                  null,
                                                                  fn!split(fv!item, ",")[5]
                                                                )
                                                              ),
                                                              local!KCIds: local!Ids[wherecontains(
                                                                " Type: Knowledge Center", local!potentialKCs
                                                              )],
                                                              a!forEach(
                                                                items: local!KCIds,
                                                                expression: fn!concat(
                                                                  fn!knowledgecenter(fv!item, "name"),
                                                                  ": ",
                                                                  fn!round(fn!knowledgecenter(fv!item, "size")/1024,2),
                                                                  "KB (",
                                                                  "Number Of Documents: ",
                                                                  fn!knowledgecenter(fv!item, "numberOfDocuments"),
                                                                  ")"
                                                                )
                                                              )
                                                            )

                                                            Output for me is this:

                                                            You may have to adjust the starting point for where User-defined KCs come into play (I've set mine at 1300 in Line 2 of the code) and I've set my upper bound as 2000 above this which finds all the ones I can see in the All Objects view I posted about earlier.

                                                          • 0
                                                            Appian Employee
                                                            in reply to Uel_M

                                                            In the spirit of understanding what you'd like to see...would a tab on the 'Monitor' view (both at individual Application level, and at all Applications level) that showed the KCs (with their properties) with a tree of the folders/sub-folders with similar properties meet your need? 

                                                          • 0
                                                            A Score Level 1
                                                            in reply to Stewart Burchell

                                                            Thanks for this, Stewart. I'll give it a try Slight smile

                                                          • 0
                                                            A Score Level 1
                                                            in reply to Stewart Burchell

                                                            As for your other comment, yes something baked into the Monitor view as you described would be great. To be able to see all KCs (tree view) and their properties in a sortable columns (ie: sort  KC by size). Similar to Designer view that has columns for Name, Description, Last Modified but to have additionals columns for size/number-of-files. Something like that. 

                                                          • 0
                                                            Appian Employee
                                                            in reply to Uel_M

                                                            I have found a registered Use Case for exactly this in the Appian Product backlog. All I can about such backlog items is that they are prioritized according to a number of different factors, and I cannot tell you when or even if) this will ever make it into the product. But rest assured there are other customers who also want to see this.

                                                          • 0
                                                            A Score Level 1
                                                            in reply to Stewart Burchell

                                                            That's great to hear, Stewart. Many thanks for the feedback.

                                                          • I may have found a way of deriving this dynamically using the content from the healthcheck files, log reader and content tools plug ins. This works quite well in our Development Environment. 

                                                            a!localVariables(
                                                              
                                                              
                                                              /*Read Health Check log file for list of folders to get the log data*/
                                                              
                                                              local!logFile: 
                                                              fn!readcsvlog(
                                                                csvPath: "health-check/hc-document-folders.csv",
                                                                filterColumName: "Type",
                                                                filterOperator: "contains",
                                                                filterValue: "Knowledge",
                                                                headers: {"UUID","Parent UUID","Name","Type","# of Author Groups","# of Viewer Groups","# of Inherited Author Groups","# of Inherited Viewer Groups","Is KC Auto Approved for Read Only Access?","Role Map"}
                                                                
                                                                
                                                                
                                                              ),
                                                              
                                                              /*Only require the UUID from the File - Would have used Excel Tools query logs function but this does not support the health check directory yet*/
                                                              
                                                              local!kcUUID: a!forEach(
                                                                items: local!logFile.rows,
                                                                expression: split(fv!item,",")[1]
                                                              ),
                                                              
                                                              
                                                              /*Using content tools functions convert the UUID to internal ID*/
                                                              /*As a text string is returned need to break the string up into component parts - the internal ID is the 2nd entry and then */
                                                              /*we only want the value after the : value */
                                                              /*KC deletions can occur and so the getcontent fucntion will return object doesnt exist message*/
                                                              
                                                              local!kcDetails: 
                                                                a!forEach(
                                                                items: local!kcUUID,
                                                                expression: 
                                                                  a!localVariables(
                                                                    local!contentObject: getcontentdetailsbyuuid(fv!item),
                                                                    local!split: split(local!contentObject, ","),
                                                                    local!kcId: if(count(local!split) > 1, tointeger(split(local!split[2],":")[2]), null),
                                                                    local!kcId
                                                                  )
                                                                
                                                              ),
                                                              
                                                              
                                                              /*Remove null values - this will remove entries where the KC has been deleted post HealthCheck file creation*/
                                                              local!filteredKCDetails:  reject(a!isNullOrEmpty, local!kcDetails),
                                                              
                                                              /*Now for each entry we can get the desired values using the KC details*/
                                                              
                                                              
                                                              local!output: a!forEach(
                                                                items: local!filteredKCDetails,
                                                                expression: 
                                                                {
                                                                  name: fn!knowledgecenter(fv!item, "name"),
                                                                  numberOfDocuments: fn!knowledgecenter(fv!item, "numberOfDocuments"),
                                                                  sizeInKB: fn!round(fn!knowledgecenter(fv!item, "size")/1024,2),
                                                                  sizeinMB: fn!round(fn!knowledgecenter(fv!item, "size") / 1024 / 1024, 2),
                                                                  createdBy: fn!knowledgecenter(fv!item, "creator")
                                                                  
                                                                }
                                                                
                                                              ),
                                                              local!output
                                                              
                                                              
                                                              
                                                            )

                                                          Reply
                                                          • I may have found a way of deriving this dynamically using the content from the healthcheck files, log reader and content tools plug ins. This works quite well in our Development Environment. 

                                                            a!localVariables(
                                                              
                                                              
                                                              /*Read Health Check log file for list of folders to get the log data*/
                                                              
                                                              local!logFile: 
                                                              fn!readcsvlog(
                                                                csvPath: "health-check/hc-document-folders.csv",
                                                                filterColumName: "Type",
                                                                filterOperator: "contains",
                                                                filterValue: "Knowledge",
                                                                headers: {"UUID","Parent UUID","Name","Type","# of Author Groups","# of Viewer Groups","# of Inherited Author Groups","# of Inherited Viewer Groups","Is KC Auto Approved for Read Only Access?","Role Map"}
                                                                
                                                                
                                                                
                                                              ),
                                                              
                                                              /*Only require the UUID from the File - Would have used Excel Tools query logs function but this does not support the health check directory yet*/
                                                              
                                                              local!kcUUID: a!forEach(
                                                                items: local!logFile.rows,
                                                                expression: split(fv!item,",")[1]
                                                              ),
                                                              
                                                              
                                                              /*Using content tools functions convert the UUID to internal ID*/
                                                              /*As a text string is returned need to break the string up into component parts - the internal ID is the 2nd entry and then */
                                                              /*we only want the value after the : value */
                                                              /*KC deletions can occur and so the getcontent fucntion will return object doesnt exist message*/
                                                              
                                                              local!kcDetails: 
                                                                a!forEach(
                                                                items: local!kcUUID,
                                                                expression: 
                                                                  a!localVariables(
                                                                    local!contentObject: getcontentdetailsbyuuid(fv!item),
                                                                    local!split: split(local!contentObject, ","),
                                                                    local!kcId: if(count(local!split) > 1, tointeger(split(local!split[2],":")[2]), null),
                                                                    local!kcId
                                                                  )
                                                                
                                                              ),
                                                              
                                                              
                                                              /*Remove null values - this will remove entries where the KC has been deleted post HealthCheck file creation*/
                                                              local!filteredKCDetails:  reject(a!isNullOrEmpty, local!kcDetails),
                                                              
                                                              /*Now for each entry we can get the desired values using the KC details*/
                                                              
                                                              
                                                              local!output: a!forEach(
                                                                items: local!filteredKCDetails,
                                                                expression: 
                                                                {
                                                                  name: fn!knowledgecenter(fv!item, "name"),
                                                                  numberOfDocuments: fn!knowledgecenter(fv!item, "numberOfDocuments"),
                                                                  sizeInKB: fn!round(fn!knowledgecenter(fv!item, "size")/1024,2),
                                                                  sizeinMB: fn!round(fn!knowledgecenter(fv!item, "size") / 1024 / 1024, 2),
                                                                  createdBy: fn!knowledgecenter(fv!item, "creator")
                                                                  
                                                                }
                                                                
                                                              ),
                                                              local!output
                                                              
                                                              
                                                              
                                                            )

                                                          Children