Insert from URL

Enters the content from a URL into a field or variable.

Options 

  • Select entire contents replaces the contents of a field or variable. If you don't select this option:

    • For a field, replaces only the selected portion of the active field, or inserts data at the insertion point. The default insertion point is at the end of the field's data.

    • For a variable that doesn't have container data, inserts data at the end of the variable's current value. For a variable that has container data, replaces the contents of the variable.

  • With dialog specifies whether to display the "Insert from URL" Options dialog box when the script step is performed.

  • Target specifies the field or variable to insert the URL content into. If the variable doesn't exist, this script step creates it (see Using variables).

  • Specify URL allows you to type the URL or to create your URL from a calculation.

  • Automatically encode URL replaces special characters with the corresponding encoded values required for URLs. For example, a space character is replaced with %20. When this option is deselected, the URL remains as it is entered. cURL options are not encoded.

  • Verify SSL Certificates verifies the SSL certificate of the server specified in the URL. If the certificate cannot be verified, users can choose to connect anyway or cancel to skip this script step. If the certificate cannot be verified and the Set Error Capture script step is set to On, Insert from URL behaves as if the server were unavailable.

  • Specify cURL options allows you to enter one or more supported cURL options as a calculation. See Supported cURL options.

Compatibility 

Product Supported
FileMaker Pro Yes
FileMaker Go Yes
FileMaker WebDirect Yes
FileMaker Server Yes
FileMaker Cloud Yes
FileMaker Data API Yes
Custom Web Publishing Yes

Originated in version 

12.0

Description 

Insert from URL supports http, https, ftp, ftps, file, smb, smtp, smtps, ldap, and ldaps protocols; other protocols are unsupported and return an error. FileMaker Pro downloads the resource that is specified by the URL to a variable or a field.

You must specify a target variable, specify a target field on the current layout, click in a field, or use the Go to Field script step before performing this script step. If Target is not specified, the data is placed in the active field. Otherwise, this script step returns an error code that can be captured with the Get(LastError) function.

For a list of picture and audio/video formats supported in container fields, see Using data in container fields.

Important  For better performance in FileMaker WebDirect, be sure that Select entire contents is selected when the target is a field.

Notes 

  • As a cloud-based integration platform, Claris Connect provides an easier way to connect your FileMaker custom app to web apps and services. See Claris Connect.

  • Insert from URL supports only UTF-8 for Specify URL. However, for Specify cURL options, you can control the character encoding of parameters in cURL options. See Supported cURL options.

  • When Target is a variable, data is normally stored as text. To store as container data, specify the cURL option described in Supported cURL options.

  • To control how long this script step waits for a response from the server, specify a value for the --max-time cURL option.

  • In FileMaker WebDirect:

    • If the With dialog option is On, this script step performs as if Automatically encode URL is selected.

    • If Select entire contents is deselected, and Insert from URL inserts content into a text field, the contents from the URL are appended to the text field. Multiple fetches can result in unpredictable results and slower performance.

  • The file protocol:

    • is not supported in FileMaker WebDirect, the FileMaker Data API, and Custom Web Publishing

    • can be used in server-side scripts only to refer to files in the Documents or temporary folder (see Paths in server-side scripts)

  • Paths returned by Get functions such as Get(DocumentsPath) and Get(TemporaryPath) are in FileMaker format and must be converted to a standard URL format before you can use them with the file protocol in Specify URL. (See ConvertFromFileMakerPath function.) An easier way to access local files is to use the Read from Data File script step, which uses these paths without conversion.

  • FileMaker Go does not support ldap and ldaps protocols.

  • If there is no content in the response from the server, Get(LastError) may return 10 ("Requested data is missing") after this script step is performed. This return value may not mean that an error occurred if the expected response is to receive no content.

Example 1 

Accesses a website and inserts a PDF into the Sales Report container field.

Copy
Insert from URL [ With dialog: Off ; Target: Customers::Sales Report ; "https://example.com/sales_report.pdf" ]

Example 2 

Inserts a map showing the customer's address in the Address Map container field.

Copy
Insert from URL [ With dialog: Off ; Target: Customers::Address Map ; "http://maps.google.com/maps/api/staticmap?center=" & Customers::Address & "&zoom=14&markers=" & Customers::Address & "&size=256x256&sensor=false&key=API_KEY" ]

Example 3 

Inserts the HTML code for https://www.apple.com.

Copy
Insert from URL [ With dialog: Off ; Target: Customers::HTML Website Code ; "https://www.apple.com" ]

Example 4 

Uses the cURL options --user and --upload-file to upload a file from a container field to a server using the credentials myusername and mypassword, and stores any results from the server in the variable $$results. For HTTP or HTTPS, the filename on the server will be the same as the filename in the container field.

Copy
Set Variable [ $file ; Value: table::container ]
Insert from URL [ With dialog: Off ; Target: $$results ; 
"https://example.com/uploads" ; Verify SSL Certificates ; 
cURL options: "--user myusername:mypassword --upload-file $file 
 --header \"Content-type: image/png\"" ]

Example 5 

Sends email via an SMTP server with a secure connection. Uses cURL options --mail-from for the sender's address, --mail-rcpt for the recipient's address, --upload-file for the file containing the message, and --user for the credentials to sign in to the SMTP server.

Copy
Set Variable [ $mail ; Value: TextEncode ( Table::Mail ; "utf-8" ; 3 ) ]
Insert from URL [ Select ; With dialog: Off ; Target: $result ; 
"smtps://smtp.example.com:465" ; Verify SSL Certificates ; cURL options: 
    "--mail-from sender@example.com 
    --mail-rcpt recipient@example.com 
    --upload-file $mail 
    --user account:password" ]

The Table::Mail text field contains the following message content, including the email body in HTML format:

Copy
From: Sender Name <sender@example.com>
To: Recipient Name <recipient@example.com>
Subject: Subject line
Content-Type: text/html; charset="utf8"
<html><body>Body of email</body></html>