This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Client side - checkOut vs. DownloadFile

CycleOp - Thursday, September 23, 2010 9:45 AM:

Hi,

Trying to copy a physical file related to a document into an external directory, I use a button on the form which calls a  Javascript code.

Using the following with DownLoad file:

// Get the URL to the file and download it

var fileURL = top.aras.getFileURLEx(myFile.node);

alert("fileURL is : " + fileURL);

var folder = top.aras.vault.GetWorkingDir();

var results = top.aras.vault.DownloadFile(fileURL);

Results in an Error for some reason....

So instead I used 'checkout' which behaves strange, since it acts like a copy: When I do checkout - The object in Aras remains checked-in.

The API reference on 'checkout' states that you can 'checkout' multiple times..Not sure how that works..

Can someone please shed some light on what's the difference between them, and what is the best way to go ?

Thanks.

Sagi / CycleOp



Brian - Saturday, October 2, 2010 9:29 AM:

Hi Sagi,

I presume there is some reason why you don't want to use the built in "Get Copy of File" on the File context menu?

Anyway, try this. If you look in item_window.js file you will find method:

 

function onDownloadCommand() {

if (itemTypeName != 'File') return true;

var workDir = top.aras.getWorkingDir(false, window);

if (workDir == '') return true;

with (top.aras) {

var vault_id = '';

var filename = getItemProperty(item, 'filename');

var fileURL = getFileURLEx(item);

if (fileURL == '') {

top.aras.AlertError(top.aras.getResource("", "item_methods_ex.failed_download_file_url_empty"));

return false;

}

else

{

var vindx = fileURL.indexOf("&vaultId");

if( vindx >= 0 )

{

vault_id = fileURL.substr(vindx+9, 32);

fileURL = fileURL.substring(0, vindx);

}

}

 

vault.clearClientData();

vault.clearFileList();

 

vault.setClientData("SOAPACTION", "GetFile");

vault.setClientData('DATABASE',top.aras.getDatabase());

vault.setClientData('AUTHUSER',top.aras.getLoginName());

vault.setClientData('AUTHPASSWORD',top.aras.getPassword());

if( vault_id )

vault.setClientData('VAULTID', vault_id);

vault.setLocalFileName(filename);

if ( !vault.downloadFile(fileURL) )

{

top.aras.AlertError(top.aras.getResource("", "item_window.failed_download_file"), "item_window: "+vault.getLastError(), top.aras.getResource("", "common.client_side_err"));

}

else

{

top.aras.AlertSuccess(top.aras.getResource("", "itemsgrid.file_succesfully_downloaded", filename, workDir));

}

}

return true;

}

 this sets the vault object up with authorisation then downloads the file.

Cheers,

Brian.

 

 

 



CycleOp - Sunday, October 3, 2010 4:09 AM:

Thanks Brian,

 

But like I wrote - I successfully managed to COPY the file to an external location by using the CheckOut API command.

Seems that if you call CheckOut without using the apply(); on the item - The checkOut behaves like a Download file.

 

For your question - I am using a button on the form to copy the physical file of the item and all of its children to an external directory in one click - A sort of "Pack & Go" solution for a customer.

 

Cheers,

Sagi, CycleOp