How to copy a file item when updating

Former Member
Former Member
I created item type "myitem" with viewable_file and native_file like Itemtype "CAD". Then, when saving "myitem", I created a method to copy viewable_file to native_file, but it does not work. Could you tell me how to do it? I would like to do the following things. 1, State before saving - viewable_file: A. pdf   -   native_file: (none) 2, Change viewable_file to B.pdf and save. 3, State after saving - viewable_file: B.pdf   -   native_file: B. pdf I created the following method with server event (On BeforeUpdate), but an error occurred and it did not work. ************************************************* var view = this.getPropertyItem ("viewable_file"); var new = inn.newItem (view.getType (), "copyAsNew"); new.setID (view.getID ()); var res = new.apply (); this.setPropertyItem ("native_file", res); ************************************************* error: Sufficient privilege is not set for 'get' operation. Server error (On AfterUpdate) also failed with an error. error: An attemp to copy file (ID = xxxx) after add in the same transaction How do I get the results I expected?
Parents
  • Former Member
    Former Member
    Hi Chris. The viewable_file and the native_file should not be the same item. After copying, convert the viewable_file to another format in the method and replace the original viewable_file. At this time, the native_file and the viewable_file will be different.
Reply
  • Former Member
    Former Member
    Hi Chris. The viewable_file and the native_file should not be the same item. After copying, convert the viewable_file to another format in the method and replace the original viewable_file. At this time, the native_file and the viewable_file will be different.
Children
No Data