Search code examples
filenet-p8filenetfilenet-content-engine

Filenet Change Document Class


I'm trying to change class for a given document and below is the code that I used

Document p8Document = Factory.Document.getInstance(p8ObjectStore,
                oldDocumentClassName, new Id(documentId));
p8Document.changeClass(newDocClassName);
        p8Document.save(RefreshMode.REFRESH);

Upon executing the code, I can see that document class is being changed successfully. Now the problem is if I run the code again for the same guid, the below line fetches the document again with the old document class name.

Document p8Document = Factory.Document.getInstance(p8ObjectStore,
                    oldDocumentClassName, new Id(documentId));

Solution

  • By using getInstance, you are not asking the server to verify the existence of the object. Use fetchInstance instead.

    From Instantiating Objects

    The getInstance methods are used to instantiate an object that references a server object that is assumed to already exist. The existence of the object is not verified on the Content Engine server, and no round trip to the server is made until you perform a function on the object

    getInstance is a way that you can setup an object while avoiding a trip to the CE server.

    The fetchInstance methods instantiate an object by first making a round-trip to the Content Engine server and retrieving ("fetching") property values.

    fetchInstance actually will retrieve the object from the CE server.