Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2011
    Posts
    176

    Unanswered: Open a file in the attachment field through script

    Dear Fellow BD users, I would like to open a file in the attachment field through script. My ultimate aim to open the pdf file in the attachment field to open with my required pdf page for example page 3 instead of page 1. Native field 'left click and right click" is not helping me since I have to pass additional parameters to the open command.

    I tried and it is possible only if the file in the attachment field is saved in the local folder of our system(extract file, open file/URL commands). If it is a big file like 250 MB size it is not practically possible everytime you open the file, this attachment field file is first stored in our local system folder and open from there. Hence the aim is to open the attachment field file from there itself through script with additional parameters.
    Any idea? Thank you in advance.
    Attached Files Attached Files

  2. #2
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Please see attached your file modified.

    Attach a PDF file the file field, enter in a page number into the new field I made, and press the button. As you can see, it will open on the correct page. Just as you want to do.

    However..... shut down brilliant databases now and reopen your database again. Now press the button to the record you attached the pdf file to above. You will notice it now doesn't work any more.

    Long story short, this is simply how Brilliant Database works. It will do exactly what you want when you attach the file, but after you close and open your database, it will no longer open that attachment you added.

    You have 2 options only to make this work permanently.

    1: Extract the file field to the system variable [$_temp] location, and run it from there. The downside as you know is that the file will have to be extracted every single time the database is launched and if your working with big files, then this is going to be slow and unacceptable.

    So I recommend.....

    2: Modify the file field that when a file is attached, a copy of the file is automatically written to the “myfiles” folder. You can then have your script open it from there. This way it runs instantly and there's no extracting. The downside however, your database must be run as Administrator as it needs to write to the myfiles folder located in Program Files.

    This maybe a problem for you. Most System Administrators don't allow people to run programs as Administrator.

    Regards
    James
    Attached Files Attached Files

  3. #3
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Have a look at this attached example.

    When you attach a file to the field, a copy of the file is saved to the myfiles folder, so this only happens once.

    When you press the button, it opens the file located in the myfiles folder on the right page.

    Regards
    James.
    Attached Files Attached Files

  4. #4
    Join Date
    Jul 2011
    Posts
    176
    Quote Originally Posted by Tubbritt View Post
    Please see attached your file modified.

    However..... shut down brilliant databases now and reopen your database again. Now press the button to the record you attached the pdf file to above. You will notice it now doesn't work any more.

    Long story short, this is simply how Brilliant Database works. It will do exactly what you want when you attach the file, but after you close and open your database, it will no longer open that attachment you added.

    Regards
    James
    Thank you James.
    Just my observation. After attaching the file BD remembs the file path temporarily and when you execute the script it is opening the file from the source not from attachment field. To confirm this, after attaching the file remove the source file. Now even without closing the BD it will not work.

  5. #5
    Join Date
    Jul 2011
    Posts
    176
    Quote Originally Posted by Tubbritt View Post
    Have a look at this attached example.

    When you attach a file to the field, a copy of the file is saved to the myfiles folder, so this only happens once.

    When you press the button, it opens the file located in the myfiles folder on the right page.

    Regards
    James.
    Yes it works. Thank you.
    Another known bug you might be knowing. Whenever you attach a file in the attachment field the database size increases. If you remove it the database size does not get reduced. To solve this I replace the file with another file of smaller size then the database size gets reduced/updated.

  6. #6
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    James and asokram,
    You guys are ABSOLUTELY amazing. Your willingness to help others out is what is keeping this software alive. There is no way that I would have ever been able to finish my project if the fine people here had not taken the time to help (and encourage) me on my Brilliant Database journey.

    I have no constructive help to add to this thread other than to say a huge thanks for what this community offers by so freely and enthusiastically helping others!!!
    Daryl G

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •