JavaScript functions

To upload a File using method code on the client-side, the following examples may be referenced.

To download a File through javascript, use the downloadFile function. For example:

aras.downloadFile(myFileItem.node);

Client-side Action to prompt for File:

function processAddingFile(file) {

var newFile = aras.newItem(“File”, file);

if (newFile) {

aras.itemsCache.addItem(newFile);

var res = aras.saveItemEx(newFile);

aras.unlockItemEx(res);

}

}

aras.vault.selectFile().then(processAddingFile.bind(this));

Form onClick event for Button:

function processAddingFile(file) {

var newFile = aras.newItem(“File”, file);

if (newFile) {

aras.itemsCache.addItem(newFile);

window.handleItemChange(“myFileProperty”, newFile);

}

}

aras.vault.selectFile().then(processAddingFile.bind(this));

Client-side setFileProperty Example:

aras.vault.selectFile().then(function (fileObject)

{

var d = aras.IomInnovator.newItem(‘CAD’, ‘add’);

d.setProperty(‘item_number’, ‘CAD_001');

d.setFileProperty(‘native_file’, fileObject);

d.apply();

});