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:
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
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.
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.
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 )
Hi paulc919 ... very interesting! Thanks for this. Will give it a go this week and keep you posted.
paulc919 this works great! Thank you for this.
Brill ! Glad to hear this ... the only downside is that it wont pick up new KC's until the Healthcheck report has run. I've extended our housekeeping app to run that logic nightly to display on a record the KC overview providing developers the ability to drill into the KC to see the document meta data ... its been quite an eye opener to see how many "old" files we had laying around on our DEV system.
I do it the following way. Notice that I use plugin "Content Tools":
a!localVariables( folders: fn!findcontentbyattribute( searchAllContent: true, contentType: "folder", attributeName: "name", searchCriteria: "*" ), kcIds: a!forEach( local!folders, if( isnull(fn!folder(fv!item, "parentFolderId")), fn!folder(fv!item, "knowledgeCenterId"), {} ) ), kcIds2: reject(fn!isnull, local!kcIds), kcIds3: rule!BK_RemoveDuplicates(local!kcIds2), kcMaps: a!forEach( local!kcIds3, a!map( id: fv!item, name: knowledgecenter(fv!item, "name"), numberOfDocuments: knowledgecenter(fv!item, "numberOfDocuments"), type: knowledgecenter(fv!item, "type"), size: knowledgecenter(fv!item, "size") ) ), a!forEach( local!kcMaps, if( or( fv!item.numberOfDocuments = 0, fv!item.type = 2/* Personal */ ), {}, fv!item ) ) )
I also use a function 'BK_RemoveDuplicates', that would be nice to have in the standard Appian repertoire:
/* The trick here is to use the union function: Apart from merging two (or more) lists, it also removes duplicates from the resulting list. */ union( cast(typeof(ri!list), {}), /* empty list */ ri!list )
Input 'list' is Any Type.
This looks good though I'd caution that in a production environment it might not be performant (at least in cases where there might be thousands or tens of thousands of procedurally generated subfolders i.e. in a personnel folder hierarchy). When I tried it, it sat "thinking" for 5 minutes then returned an error. Luckily it didn't do anything worse than that