Cookie Consent by TermsFeed

Finding Assets Without a Collection or Channel JavaScript Sample

September 6, 2019

Browng an Asset Repository only shows you 50 assets per page. There is not, currently, an easy way to see which assets in your repository might be missing a channel or collection.

You can use the snippet of JavaScript below in your JavaScript console to find these assets.

  1. Sign into OCE
  2. Under Administration click Asssets
  3. Click the Asset Repository you are interested in
  4. Look in the URL and note the ID
  5. Open Developer Tools, specifically the JavaScript Console
  6. Paste the code below and press enter
// You need to be in the browser and signed in for this to work in your JavaScript Console
// Asset Repository ID we want to work with
// This is a sample
// const strRepoID = 'F3FD7F04253857F662CF6EB68D8FAF36066C5A491364';
// TODO: Replace this with YOUR REPO ID
const strRepoID = 'REPLACEME';

// Relative URL to fetch all the assets for our specified repository id
const strURL = `/content/management/api/v1.1/items?repositoryId=${strRepoID}&limit=9999&fields=ALL`;

// Function to list the ID's of the assets that have no collections assigned to them
const fnFindAssetsWithoutACollection = (data) => {
    const arIDs = data.items.filter(item => item.collections.data.length < 1).map(item => item.id);
    console.log('Assets without a collection', arIDs.join(', '));
};

// Function to list the ID's of the assets that have no channel assigned to them
const fnFindAssetsWithoutAChannel = (data) => {
    const arIDs = data.items.filter(item => item.channels.data.length < 1).map(item => item.id);
    console.log('Assets without a channel', arIDs.join(', '));
};

// Invoke all the things!
$.get(strURL).then(fnFindAssetsWithoutACollection);
$.get(strURL).then(fnFindAssetsWithoutAChannel);

Related Images



© 2020 Jason Stortz (version 20200114-085855)