Jump to content

Opening local FM file with an Import Script that needs a variable file name


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

Recommended Posts

I am trying to open my (local) FM 14 Pro file [which has an auto-exec "Import Script"] but the script needs a variable file name.

How do I pass this variable file name into Filemaker at 1) the time of the file open or 2) at the time of running the script (if I switch to manual execution)?

Is #1 by using the fmp:// syntax from a web browser external to FM?  (or is that syntax just for use when invoked from INSIDE a FM file?)

Edited by fm8443
Link to comment
Share on other sites

It's an Excel file in a folder.  File name and folder name may change each time.  Always known by me.

(To be clear - I may not have the import script auto-execute if I can't do #1.  I may just run the script manually if I can do #2 - however I want to operate this either way with a macro program (looping through different files in known locations).)

Link to comment
Share on other sites

3 hours ago, fm8443 said:

I am trying to open my (local) FM 14 Pro file [which has an auto-exec "Import Script"] but the script needs a variable file name.

I don't understand the basic situation here. You are trying to open your local FMP file from where? And where is the "variable file name" kept?

Edited by comment
Link to comment
Share on other sites

@comment -- I will be using Keyboard Maestro. KM will generate each filename, folder name and initiate FM (or FM Script) for each iteration -- hopefully passing these variables into FM (on file open) or FM Script.  KM will loop through multiple iterations. 

Link to comment
Share on other sites

4 minutes ago, fm8443 said:

I will be using Keyboard Maestro.

I am afraid I am not familiar with Keyboard Maestro. IIUC, it's a keystroke macro utility. If so, your question could be posed as: can I run an import script and type in the path to the source file at runtime? I don't think that's possible directly - but perhaps you might have the script open a custom dialog with a global input field where the macro could type in the path. Then set a variable to the contents of the global field and use it in the import script.

Caveat: thoroughly untested, written entirely off the top of my head.

  • Like 1
Link to comment
Share on other sites

I've got it partially to work but have hit syntax error/s:

From my Safari URL Box I run:

fmp://Admin:@~/Filemaker_DATA/MAIN_ZZZZ_Database/MAIN_ZZZZ_Database?script=MAIN_Add_ADP_Report_All_Steps&param="file:Filemaker_DATA%2FMAIN_ZZZZ_Database%2FUNALTERED_MONTHLY_REPORTS%2F2016_ADP%2Fadp-report-4-2016.xls"

This does startup my FM 14 Pro data file and starts to run the MAIN_Add_ADP_Report_All_Steps script.  This script is:

set variable [$adp_report ; Value: Get ( ScriptParameter ) ] 
Import Records [Source: "$adp_report" ; Worksheet: "" ; Add; Mac Roman ] 

This script fails (when trying to do the "Import Records" step presumably) with error message:

"The file "$adp_report" could not be found and is required to complete the operation".

Am I getting the syntax wrong for the &param part of the FMP:// command?  
Or using Get ScriptParameter incorrectly to set the Excel filename variable $adp_report ?

[ I have also tried the fmp:// command without the double quotes on the param= part........to no effect. I get exactly the same error as described. ]

 

Edited by fm8443
Link to comment
Share on other sites

As-is, I can't (?) turn Script Debugger on because I'm initiating everything externally from the fmp:// url

But if I take the param= part and simply copy the string:
 file:Filemaker_DATA%2FMAIN_ZZZZ_Database%2FUNALTERED_MONTHLY_REPORTS%2F2016_ADP%2Fadp-report-4-2016.xls

into the "Import File" box (replacing the variable $adp_report ) then the command & script works!

I don't understand why my param= part is not setting the script parameter which should be setting the $adp_report variable.

Edited by fm8443
Link to comment
Share on other sites

Try running the URL with the file already open, and the Script Debugger turned on.

Or temporarily make the variable $$adp_report, so you can check it's value in the Data Viewer afterwards.

  • Like 1
Link to comment
Share on other sites

1) I did this:  "Try running the URL with the file already open, and the Script Debugger turned on."

I get the error message before seeing anything in Script Debugger's "Current" Window.  
Seems like $adp_report is not getting passed the param / is not being set.

2) I changed the variable to $$adp_report twice in the script which is now:

set variable [$$adp_report ; Value: Get ( ScriptParameter ) ] 
Import Records [Source: "$$adp_report" ; Worksheet: "" ; Add; Mac Roman ] 

No effect. Got exactly same result in Script Debugger's "Current" Window etc.

Link to comment
Share on other sites

UPDATE:  Think I've found the problem:

I had a sub-script called IMPORT EXCEL called by my Top Script (MAIN_Add_ADP_Report_All_Steps).

My 2 script steps:

set variable [$$adp_report ; Value: Get ( ScriptParameter ) ] 
Import Records [Source: "$$adp_report" ; Worksheet: "" ; Add; Mac Roman ] 

were in the wrong script.  I moved them into the top-level script and out of the IMPORT EXCEL sub-script and it now appears to work....

Link to comment
Share on other sites

This topic is 2787 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.