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 - Renaming a vault file

[email protected] - Tuesday, April 7, 2015 7:12 AM:

There are files in our vault which now have an inconsistent file name. Rather than re-loading all the files again, it makes sense to rename them.

When I try to rename the file in a File record, with version=0, the actual file in the vault is not renamed.

I've found other posts that indicate I should use

Item result= inn.newResult("OK");

CCO.ExportImport.AddFileToRename(newitm.getID(),new_file_name,result.dom);

I've tried this with no joy (I get no errors either, so it's doing something)

I can't find any documentation on CCO or mention of the ExportImport or AddFileToRename in any documentation. What am I missing?

Is there a proper example of using AddFileToRename?

Is there another way?

(Aras 9.4SP2)

 



[email protected] - Tuesday, April 7, 2015 1:57 PM:

So by a process of trial and error I've managed to get this to work, but I still ask where the documentation is.

For the records, here's what works:

//'this' is in the context of a single "File" item.

    Item newitm = inn.newItem("File", "edit");
    newitm.setAttribute("where", "id='" + this.getID() + "'");
    newitm.setAttribute("version", "0");    
    newitm.setProperty("file_type", FileType);
    newitm.setProperty("filename", NewName);
    Item result= inn.newResult("OK");
    CCO.ExportImport.AddFileToRename(this.getID(),NewName,result.dom);
    newitm = newitm.apply();

 



DavidSpackman - Thursday, April 23, 2015 5:22 PM:

Hi Jason,

 

In your first example, did you use the ID of the file you where trying to rename?

The (working) code I use is similar to your first example. 

 

Innovator inn = this.getInnovator();

string fileID = this.getID();

string newFileName = "newFileName.ext";

CCO.ExportImport.AddFileToRename(fileID, newFileName, inn.newXMLDocument());



[email protected] - Thursday, April 30, 2015 9:27 AM:

Hi David,

You can see I am calling this.getID() in the call to AddFileToRename, so yes I am passing the file ID to the call.

it seems the main difference is the use of inn.newXMLDocument() rather than inn.newResult("OK").dom

however that differs,  and the use of an Aras Item to action the change.

Could the different be in where the calls are made?

 

Regards,

Jason.



DavidSpackman - Friday, May 1, 2015 1:31 AM:

Hi Jason, 

 

It should not matter as long as you are passing the correct ID of the file to be updated.

How / where do you call your method from?

 

If you change your method to match my example, is the rename successful?

 

Dave