Jump to content
Server Maintenance This Week. ×

Inserting a new file with Title, Container, File Type, File path with a button script.


This topic is 370 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

 It will ask to select the file, add a new record. It will insert the Title Field Name, add the filetype extracted from container field, but when getting the path it is extracting absolute path not relative path.

*Ex: /Volumes/Macintosh HD/Users/Username/filename.pages         This does not let me open the related application file.

file://Macintosh HD/Users/Username/Documents/Document Name.pages.       This will. This is what I want.

I have tried everything I can think of.

 

Set Error Capture [ On ]

New Record/Request

Set Variable [ $file; Value:Documents::Document ]

Show Custom Dialog [ Title: "Import Single Document"; Message: "Select the Document you want to import."; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]

Insert File [ Documents::Document ] [ Filters ]

[ "All": ( * ) ]
[ Storage method: Reference ]
[ Display content ]
[ Compression: Never compress ]

If [ Get (LastError) = 0 ]

Set Field [ Documents::Title; GetContainerAttribute ( Documents::Document ; "filename" ) ]

Set Field [ Documents::File Extension; Right ( Documents::Title; Length ( Documents::Title ) - Position ( Documents::Title; "." ; Length ( Documents::Title );-1)) ]

Set Field [ Documents::FilePath; GetContainerAttribute (Documents::Document ; "externalFiles" ) ] End If

Link to comment
Share on other sites

It's hard to understand what your question is about. You say:

3 hours ago, linuxguy123 said:

This does not let me open the related application file.

but you're not telling us how you're trying to open it.

 

It might be worth noting a few things:

1. When you insert a file into a container field as reference only, the container field contains the relative and the absolute paths to the inserted file. In your example, the field might contain (assuming that your FMP file also resides in the Documents folder):

file:filename.pages
filemac:/Macintosh HD/Users/Username/Documents/filename.pages

and you can extract the absolute path using a calculation of:

GetValue ( YourTable::YourContainerField ; 2 )


2. The path you get from: 

 GetContainerAttribute ( YourTable::YourContainerField ; "externalFiles" ) 

is a POSIX path. The paths stored in the container field are Filemaker paths. In version 19 or higher, you can use the ConvertFromFileMakerPath() and ConvertToFileMakerPath() functions to convert a path to a different format. In previous versions you can do your own conversion. Apparently, you want a path in the URL format - which you could get simply by prepending "file:///" to the path you already have.


3. You can always open the inserted file by double-clicking the container field. 


See also:
https://fmforums.com/topic/55815-view-a-pdf-file-from-a-script/?do=findComment&comment=263575&_rid=72594

 

 

Link to comment
Share on other sites

This topic is 370 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.