Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

  • 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

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

 

 

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.