Skip to content

Versioning

When a file is checked into an asset, a snapshot is created with a context. While the context can be any string, the default context is "publish". Everytime a file is checked into an asset with a context that already exists, the checked in file is versioned up.

First Check-in

To start, the file will be checked in with the default "publish" context. With this context, it is not required to specify a context.

The first time a file is checked into an asset, it will have a version of 1 (often display as v001). To do this, we will use the simple_check method.

let file_name = "whatever.jpg";

// first create an asset
// Give a name for the asset.  Often, this is just the file name
let asset_name = file_name;

let data = {
    name: asset_name,
    status: 'Pending'
}

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

// First create an asset to check the file into
let asset = await call_tactic("insert", kwargs);


// then check-in the file to the asset
let context = ""
let options = {}

let kwargs2 = {
    search_key: asset.__search_key__,
    context: context,
    options: options,
    file_path: file_name,
    mode: "uploaded"
}

let snapshot = await call_tactic("simple_checkin", kwargs2);

//console.log(snapshot.code)
console.log(snapshot.version)

This will return a version of 1.

Second Checkin

When the file is checked in again (after changes have been made to the file) by calling the simple checkin method again:

// then check-in the file to the asset
let context = ""
let options = {}

let kwargs = {
    search_key: asset.__search_key__,
    context: context,
    options: options,
    file_path: file_name,
    mode: "uploaded"
}

let snapshot = await call_tactic("simple_checkin", kwargs);

//console.log(snapshot.code)
console.log(snapshot.version)

This will return a value of 2.

Continued check-ins will increase the versions linearly.

Check into another context

The default context of a check-in is "publish". This context is generally used when only a single file is checked into the asset. An sObject has the capability of checking in multiple different files in different context, which will be versioned separately.