Skip to content

Collections

Collections are a list of assets and are a great way to organize assets. An asset can be placed in any number of collections, and since a collection itself is an asset, it can also be placed in another collection.

Create a collection

let data = {
    name: "proposals",
    user_keywords: "sales, documents, final",
    _is_collection: 'true',
    status: 'Pending'
}

let kwargs = {
    search_type: "workflow/asset",
    data: data
}

let collection = call_tactic("insert", kwargs);

Add assets to a collection

Once you have a collection, either by searching for one or by creating a new shown above, you can assets to these collections

// from the collection created above
let collection_code = collection.code;

// an asset list, we have search for (using query or expr methods)
let asset_codes = ["ASSET00123", "ASSET00034", "ASSET00324"]

let search_type = "workflow/asset_in_asset";

asset_codes.forEach( asset_code => {
    let data = {
        parent_code: collection_code,
        search_code: asset_code
    }
    call_tactic("insert", { search_type: search_type, data: data } );
} );
}

Remove assets from a collection

The follow remove all of the items from a collection. Of course, you can be more selected by deleing only the items you wish to:

// from the collection created above
let collection_code = collection.code;

// find all of the assets in a collection
let filters = [['parent_code', collection_code]]

let search_type = "workflow/asset_in_asset"

let kwargs = {
    search_type: search_type,
    filters: filters
}
let items = await call_tactic("query", kwargs);

// remove all of these items
items.forEach( item => {
    call_tactic("delete_sobject", { search_key: item } );
} );

Collection Keywords

Since collections are assets, they can also have keywords associated with them to find them in a search. Also all assets in a collection will acquire the keywords of the collections they belong to.

Note

If an assets belonds to two collections with the same keyword, the asset will only lose that keyword from a search if it is removed from both collections.