The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Insert File Attachment
Posted: 26 Aug 08 11:18 AM
|
I need to invoke the Insert:File Attachment funciton. The same one shown in the insert menu.
The difference is that I need to invoke it from a button instead of the menu?
Seems simple but I haven't been able to figure it out? Any clues?
Basically, here is my goal:
1) Insert file into attachment tab from another form using a button 2) Once its inserted, show on the same form that the file is attached using a flag like "Attached". If its not attached, do not show the word "Attached"
Can someone give me the steps as how this can be achieved please?
Thanks |
|
|
|
Re: Insert File Attachment
Posted: 26 Aug 08 12:05 PM
|
Hi Amer,
The following will launch the insert file attachment function:
Application.BasicFunctions.DoInvoke "Function", "Insert:FileAttachment"
Once the file is attached it will be visible under the Attachment tab.
I think this form is hard coded so you cannot access it to add/change your flag - unless you code for this yourself which would mean a new form, menu etc...
Cheers,
Steve
|
|
|
|
Re: Insert File Attachment
Posted: 27 Aug 08 1:21 AM
|
Hi Amer, I've had a similar problem, I needed some extra information about my attachments (like Categories, Original Path etc..) So I've created an ATTACHMENT_EXT table that stores the information and a new attachment form where the information is shown.
To create a new attachment, I simply create a new entry in the ATTACHMENT and ATTACHMENT_EXT table, then combine the attachID and original filename to create the SLX internal filename, finally copy the file with the new name to the SLX documents folder. This way, you can even store your files in a subfolder of the documents folder, you just have to include the subfolder name and backslash in the FILENAME field of the ATTACHMENT row in the database. After copying the file, you can check if the file is actually there (using the standard Windows Scripting methods) and set your flag.
Just let me know if you need more info on this...
Stefan |
|
|
|
Re: Insert File Attachment
Posted: 27 Aug 08 7:56 AM
|
Thanks for you responses.
Steve, your code worked perfectly. Much appreciated.
As for the flag situation, I decided to go with a data grid that gives the last updated date of the file. I modified the sql within the grid to relay this info.
Thanks. |
|
|
|
Re: Insert File Attachment
Posted: 20 Feb 09 2:43 AM
|
Hi
I've also tried that code on a button but i get the following message box: Unable to add an attachment to this entity because the KeyFieldName APPLICATIONID does not exist in the Attachment table. |
|
|
|
Re: Insert File Attachment
Posted: 20 Feb 09 7:58 AM
|
If you wanna add an attachment for custom entity (in your case it is Application), then you should add custom field to ATTACHMENT table. This field must have same name as key field name of your entity (in your case it is APPLICATIONID). Do this with SLX Database Manager. |
|
|
|
Re: Insert File Attachment
Posted: 23 Feb 09 2:01 AM
|
cool, it works... so whenever i try attaching a file, i should make sure that the keyfield that its looking, exists in the attachment table? |
|
|
| |
|
Re: Insert File Attachment
Posted: 26 Nov 10 2:42 AM
|
I've tried to add own keyfield to attachment table, but in DB manager it's forbidden(add field button inactive for this table).
Is it some way to get attachmentid after file had been saved to DB with Application.BasicFunctions.DoInvoke "Function", "Insert:FileAttachment" ? |
|
|
|