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 - Delete local copy of file after check in

Brian - Thursday, May 14, 2009 9:04 PM:

Hi All,

I am looking to implement a method to delete local copies of files after they are checked into Innovator.

The actual delete process does not look difficult. I am not sure which event to attach a new method to as I can't find the "check in" method to run this "delete file" method after.

On a wider scope where is the core code telling Innovator what to do in default situations, like Save? It is not listed in the Methods TOC.

Thanks,

Brian.



SamsAn - Friday, May 15, 2009 4:33 AM:

To listen "check in":
1. "File Field" is on a form case. Write javascript code on the form. The code should use DHTML attachEvent method for the field element to listen "check in".
2. "File Field" is in relationships grid case. It is possible to overwrite checkin_commonPart function from OnSelectRow (for example) event method of corresponding RelationshipType.
3. In general, "check in" operation is executed through internal api checkinFile method (Aras.prototype.checkinFile = function Aras_checkinFile(fileNd, win)...) located in InnovatorClientjavascriptitem_methodsEx.js file. You can fake (at your own responsibility) this method to call your additional code.

To make javascript hook for item saving:
1. Use OnFormPopulated Form Event (it is called after operations like lock/unlock/view/save, but i believe it is possible to filter save using a special trick).
2. Call internal api function inside a form like below:
  top.aras.registerEventHandler("ItemSave", window, ItemSaveListenerFunc);
3. "Item Save" operation is executed through internal api saveItemEx method (Aras.prototype.saveItemEx = function Aras_saveItemEx(itemNd, confirmSuccess, doVersion)...) located in InnovatorClientjavascriptitem_methodsEx.js file. You can fake (at your own responsibility) this method to call your additional code.

SamsAn.
Original Mind Any Level Innovator Solutions Free-Lancer, http://sites.google.com/site/caraacc



Brian - Monday, May 18, 2009 1:22 AM:

Thanks for the response. Unfortunately it doesn't really answer my questions in a useful way.

Thinking on it over the weekend I thought I would attach a serverEvent to the File ItemType, triggering on the onAfterUpdate event.

This event certainly appears to be run whenever file checkIn is selected from the context menu.

The confusing thing now is that triggering on the onAfterUpdate does not delete the file. It also does not throw an exception. It does perform the check In. Just to experiment I triggered the same method off onBeforeUpdate and the entire operation seems to work OK. The file is checked In AND the local copy of the file is deleted.

This seems counter intuitive to me. If I am deleting the file before the update then surely the checkIn has not occured yet? If that is the case how can the checkIn succeed since I have deleted the file it is checking in? Or have I misunderstood when the onBeforeUpdate is called in relation to saving and check In of the File?

Regards,

Brian.



SamsAn - Monday, May 18, 2009 7:22 AM:

I understand you mean the following scenario.
1. User locks a Document instance with a file attached.
2. User checks out the file from the Document. Local copy of the file is created.
3. User modifies the local copy of file.
4. User clicks "check in".
5. User saves the document (the file changes are sent to Innovator Server/VaultServer). Saved successfully.
6. The local copy of file should be deleted (it is desired behavior). So, the changed file is only stored inside Innovator Server/VaultServer now and is not stored on Client computer.

Not sure why you are going to delete LOCAL copy of file from server-side method. In common case, it is impossible (or very difficult) to reach local copy of file (located on Client computer) from server-side method (it is executed inside Innovator Server, Innovator Server is in Web and does not have access to the client computer file system).
I believe the options proposed in my previous post can solve your problem (if i understand it correctly).

SamsAn.
Original Mind Any Level Innovator Solutions Free-Lancer, http://sites.google.com/site/caraacc