1

I am a student and I'm new to Filenet. I am trying to do the test code on file moving.

Document doc = Factory.Document.getInstance(os, ClassNames.DOCUMENT, new Id("{33074B6E-FD19-4C0D-96FC-D809633D35BF}") );
FileStorageArea newDocClassFSA = Factory.FileStorageArea.fetchInstance(os, new Id("{3C6CEE68-D8CC-44A5-AEE7-CADE9752AA77}"), null );

doc.moveContent(dsa);
doc.save(RefreshMode.REFRESH);

The thing is that I can fetch the document by its path like this ,

doc = Factory.Document.fetchInstance(os, "/DEMO/MASTERFILE/ZONE-X/Org.No-XXXXX/XXXX-X-XXXX-X.TIF",null);

but I can't fetch the StorageArea by the path, it only takes ID. Is there a way to move a file easily than this? How can I get ID with path without using queries?

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
Archangle
  • 312
  • 1
  • 4
  • 23

2 Answers2

0

There is no other way to fetch FileStorageArea by its path other than issue a query and filter by RootDirectoryPath property.

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
-3

You can access the ID of the document using the path:

        //Get ID of the Document 
        StringBuffer propertyNames = new StringBuffer();
        propertyNames.append(PropertyNames.ID);
        propertyNames.append(" ");
        propertyNames.append(PropertyNames.PATH_NAME);

        PropertyFilter pf=new  PropertyFilter();

        FilterElement felement= new FilterElement(Integer.valueOf(0),Long.valueOf(0),Boolean.TRUE,propertyNames.toString(),Integer.valueOf(0));
        pf.addIncludeProperty(felement);

        Document document = Factory.Document.fetchInstance(os, ruta, pf );

        idDocument = document.get_Id().toString();

and in the idDocument string you have it. Hope it helps.

abarisone
  • 3,707
  • 11
  • 35
  • 54
icrovett
  • 435
  • 7
  • 21
  • Good answer. The interesting thing would be to understand why it's not possible to fetch by path... – abarisone Apr 28 '17 at 08:38
  • 2
    @abarisone This answer does not make sense. An object's ID is always there however the object is fetched; those manipulations with PropertyFilter are useless. Not to say it does not address the question in any way. – ᄂ ᄀ May 04 '17 at 18:24