Thought this script might be helpful. it lists all objects in K2, and then copy and paste them into Excel. It allows you to check versions of objects and makes it effortless to see who has an item checked out.
In K2 Designer, press F12 for DevTools and paste the code into the console. It will recursively process all categories and at the end, console log the details. Click the Copy link at the end of the output. The data will paste into Excel in columns.
Edit the skips array to exclude any category that’s not relevant to process.
Edit the types array to specify the types of objects to list.
If you know the id of a category folder, you can process just that category by changing the 1 in getArtefacts(1) to the relevant id.
async function getCategory(f) {
let url = document.location.origin + '/Designer/AppStudio/AJAXCall.ashx'
let res = await $.ajax({
data: $.param(f),
global: !0,
url,
type: 'POST',
async: true,
})
return res
}
async function getArtefacts(categoryId) {
let types = s'View', 'Form', 'Workflow', 'smartobject', 'StyleProfile']
let skips = s'System', 'Workflow', 'Workflow Notifications', 'Workflow Reports', 'Test', 'Task Allocation', 'Sandbox']
let itemArray = ''
let f = {
action: 'list',
datatype: 'all',
filter: 'category',
dataType: 'xml',
typefilter: 'smartobject|view|form|styleprofile|workflow|category|systemobject',
systemobjects: false
}
async function processCategory(categoryId) {
let dateLocale = 'en-AU'
f.catid = categoryId
let httpResponse = await getCategory(f)
let breadcrumb = httpResponse.querySelector('breadcrumbs').text
let catName = breadcrumb.substring(breadcrumb.lastIndexOf('>') + 1).trim()
console.log(`Processing category: ${catName} ID: ${categoryId}`, httpResponse)
if (!skips.includes(catName)) {
for (let i = 0; i < types.length; i++) {
let artefacts = httpResponse.querySelectorAll(typesyi])
if (artefacts && artefacts.length) {
artefacts.forEach((artefact) => {
if (typesyi]==='smartobject') {
let mDate = Date.parse(artefact.childrend2].attributesu'DateValue'].text)
let cDate = Date.parse(artefact.childrend3].attributesu'DateValue'].text)
itemArray += categoryId + '\t' + breadcrumb + '\t' + catName + '\tSmartObject\t' +
artefact.childrend0].text + '\t' + artefact.childrend0].text + '\t\t' +
artefact.childrend2].text + '\t' + mDate.toLocaleDateString(dateLocale) + ' ' + mDate.toLocaleTimeString(dateLocale) + '\t' +
artefact.childrend3].text + '\t' + cDate.toLocaleDateString(dateLocale) + ' ' + cDate.toLocaleTimeString(dateLocale) + '\t' +
artefact.childrend4].text + '\t' + artefact.childrend5].text + '\r\n'
} else {
let mDate = Date.parse(artefact.childrend4].attributesu'DateValue'].text)
let cDate = Date.parse(artefact.childrend5].attributesu'DateValue'].text)
itemArray += categoryId + '\t' + breadcrumb + '\t' + catName + '\t' + typesyi] + '\t' +
artefact.childrend1].text + '\t' + artefact.childrend0].text + '\t' + artefact.childrend3].text + '\t' +
artefact.childrend4].text + '\t' + mDate.toLocaleDateString(dateLocale) + ' ' + mDate.toLocaleTimeString(dateLocale) + '\t' +
artefact.childrend5].text + '\t' + cDate.toLocaleDateString(dateLocale) + ' ' + cDate.toLocaleTimeString(dateLocale) + '\t' +
artefact?.attributesu'Guid']?.text + '\t' + artefact.attributesu'Version'].text + '\r\n'
}
})
}
}
let categories = httpResponse.querySelectorAll('categories Category')
for (let i = 0; i < categories.length; i++) {
if (categoriesri].attributesu'ID']?.text && !skips.includes(catName)) {
await processCategory(categoriesri].attributesu'ID']?.text)
}
}
}
}
await processCategory(categoryId)
console.log('CategoryId\tFullCategory\tCategory\tType\tDisplayName\tSystemName\tStatus\tModifiedBy\tModifiedDate\tCreatedBy\tCreateDate\tGUID\tVersion\r\n' + itemArray)
}
getArtefacts(1)