Peter Berger - Thursday, March 3, 2016 11:13 AM:
Hello,
I wrote a clientside program tho download a file of a document using c# . After editing the file I want to load it up again, but in a new version.
I' using the well known methods
Item fileToAttach = MyInnovator.newItem("File", "add");
fileToAttach.setProperty("filename", name);
fileToAttach.attachPhysicalFile(filepath);
fileToAttach.apply();
Item doc_file = MyInnovator.newItem("Document File", "add");
doc_file.setProperty("related_id", file.getID());
doc_file.setProperty("source_id", doc.getID());
doc_file.apply();
doc.lockItem();
doc.addRelationship(doc_file);
doc.apply();
doc.unlockItem();
This works. But no new version is created.
Ho can I do this?
I already reat the topic
4.2 Built in Action Methods
of the programmers guide, but I dont know how to deal with it.
Can anybody please give me a short example to operate with a new verion of a document (Item)?
Any help would be appreciated.
Eric Domke - Thursday, March 3, 2016 9:05 PM:
Forgive any errors in my code. However, I believe the following should get you closer to what you want. The key to getting the document to actually version is to do an actual AML "edit" of the document between the lock and unlock steps. While not necessarily required, it might also be easier and/or more performant to apply all of the AML in one go as opposed to applying each item individually (as shown below).
Item fileToAttach = MyInnovator.newItem("File", "add");
fileToAttach.setProperty("filename", name);
fileToAttach.attachPhysicalFile(filepath);
Item doc_file = MyInnovator.newItem("Document File", "add");
doc_file.setPropertyItem("related_id", fileToAttach);
doc_file.setProperty("source_id", doc.getID());
Item doc_edit = MyInnovator.newItem("Document", "edit");
doc_edit.setId(doc.getID());
doc.lockItem();
doc_edit.addRelationship(doc_file);
doc_edit.apply();
doc.unlockItem();
Peter Berger - Friday, March 4, 2016 5:18 AM:
Thnks for your answer,
but it did not work. After a period of testing, and studying the Programmersguide as well as the API-Documentation, I found out how to reach the goal.
the IOM.dll and the others provide just some basic methods to deal directly with the items. For having the full control, using the AML is nessarry.
In my case its the following line:
Item docAmlAnswer = MyInnovator.applyAML("<AML> <Item type="Document" action="version" id="" + doc.getID() + ""/></AML> ");
Maybe it helps some other people.