"client_ZipSelectedRelatedFiles" method Error.

Hi All,

I have an issue about client_ZipSelectedRelatedFiles method that I got from Aras GitHub lab which is useful for mutiple download functionality,once  I added a line " fileItem.setProperty("locked_by_id", "30B991F927274FA3829655F50C99472E");" then It pops up error that said ARAS object:"undefined" which confused me, any ideas? Thanks!

Parents
  • Hi,

    getItemById is not intended to be used with additional filter properties. It´s a simply way to make a get query that returns the complete item. I personally prefer the regular get queries due to performance reasons.

    When you want to add an additional filter, make a normal get, e.g. like:

    var filteItem = inn.newItem("File","get");
    [...your additional code...]

  • Hi Angelalp,

    I did updated the a piece of code as you suggested, using regular get queries instead of getItemById.

    it looks fine until the code runs to the red line I marked which downloading files as Zip file then shows the same error again. Is that "fileItem" should  not be a item object or something else? Appreciate it.

      

  • Hi Jenli,

    my tip was not completely correct.

    aras.downloadFile always require the full item, so according to my knowledge, you may have to use it with getItemById. I never used in another way, e.g. this one is my variant (custom properties). 

    var fileItem = aras.getItemById("File", dom.firstChild.getAttribute("id"));
    aras.downloadFile(fileItem, zipFileName + ".zip");

    Does downloading the zip file work when you just the sample "as is"? I wonder why you wanted to add the "locked_by_id" filter. "File" items are normally not locked/unlocked. 
    The downloadFile function will download you the final zip result. Each filter you want to add you have to provide before so the used id list for the involved Files is correct.

    When you use one of the newer Innovator Versions (late Innovator 11 or Innovator 12) I would also recommend to remove all "top." prefixes. You will not need them and sometimes they can lead to trouble.

Reply
  • Hi Jenli,

    my tip was not completely correct.

    aras.downloadFile always require the full item, so according to my knowledge, you may have to use it with getItemById. I never used in another way, e.g. this one is my variant (custom properties). 

    var fileItem = aras.getItemById("File", dom.firstChild.getAttribute("id"));
    aras.downloadFile(fileItem, zipFileName + ".zip");

    Does downloading the zip file work when you just the sample "as is"? I wonder why you wanted to add the "locked_by_id" filter. "File" items are normally not locked/unlocked. 
    The downloadFile function will download you the final zip result. Each filter you want to add you have to provide before so the used id list for the involved Files is correct.

    When you use one of the newer Innovator Versions (late Innovator 11 or Innovator 12) I would also recommend to remove all "top." prefixes. You will not need them and sometimes they can lead to trouble.

Children
  • Hey Angelalp,

    the code should works.

    var fileItem = aras.getItemById("File", dom.firstChild.getAttribute("id"));
    aras.downloadFile(fileItem, zipFileName + ".zip");

    What I am trying to do is locking the file before downloading it, so the other users will not download it  until the I upload this file is done. If like you said the " File " Item is no that kind of locked/unlocked properties, so any suggestions that how to blcok others from downloading action if there is already has a user just did download action and not done with the upload?  Thanks very much Angelalp.

  • Ah interesting scenario. Does this one happen very often in your company? I never have seen users being this fast in my many years I used the software that they download before upload. But I understand this can happen when you have a lot of very large files.

    You cannot lock or claim files by default due to permission restrictions. When you use Enterprise Search you might can use the "Indexed On" property as alternative filter.

    Maybe it´s also possible to do a File.exstings(myFile) check within the C# Part of the Method, but I am not sure.

    I wouldn´t solve this one on "File" level cause it may require you change a lot of core settings. I assume your files are always attached to some Part or Document? Then you could check the lock status of the affected Parts and Documents.

    You can apply this kind of filter to the code that is used to build your "idlist". I don´t remember exactly how the community project build the idlist.

    I my case I use a custom query that collects the ids of the files that shall be downloaded. According to the download mode, it´s e.g. a multilevel Part "get" query. Within such a query you could also select the "locked_by_id" property of these parts. Then you can check if one of them is still locked. This way you could throw an error message before building the zip file.

  • Hi Angelalp,the reason I am working on this is bcz I am trying to implement a CheckIn/CheckOut functionality into Aras, I try to use “”multiple download“”as CheckOut function, that is why I'd lock the file before CheckOut, so others will not edit the file for synchronization purpose.

  • Angelalp, it is so odd that I got the File's Parent item which is "Document" Item,and then i trying to set that Document locked,  in that case it still throw the error as long as i use setProperty() function, it seems that the error happened everytime once i use "setProperty()..."