Jump to content
Sign in to follow this  
fm8443

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

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

Share this post


Link to post
Share on other sites

How is this file name variable? Does it change each time you open the file? Is it in a known location, but the name changes?

Share this post


Link to post
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).)

Share this post


Link to post
Share on other sites

Well, you can _not_ specify a location, and you should get a prompt asking for the file.

Screen Shot 2016-08-25 at 8.57.09 am.png

Share this post


Link to post
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

Share this post


Link to post
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. 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Yes, KM should be able to issue keystrokes on top of FM's dialogs.  Not too clean a solution but may work.

But can I startup FM 14 Pro on the Mac by using the fmp:// syntax (and pass a script param and vars) from a web browser e.g. see Example in section 4 here: http://www.twdesigns.com/fmp_url_protocol/  ?  If so this would be ideal.

Share this post


Link to post
Share on other sites

Yes, that can be done - the FM file needs to be in the Documents directory for something like this to work:

fmp://user:pwd@~/Database.fmp12?script=Test&param=DoesThisWork

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

What's the value of $adp_report when you run with the Script Debugger on?

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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....

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Similar Content

    • By Jim Gill
      This is probably one of those questions which separates me from people that make money as developers and those that don't (that would be me).  I have a simple script that compares two variables. The variables are populated with  text (Peoples Names).  Basically, if the the two variables are TRUE (the variables are equal) I want to stop the script.  Despite the two variables being equal - the IF continues.  I have noted when I use the same numbers to populate the variables - the script works as expected.  Please tell me Filemaker is smart enough to evaluate text in variables.   Below is the my script and attached is a screenshot of my debugging efforts.   
      As always - thank you to the people here which share your wisdom - a big reason I love Filemaker so much.  
      Jim
      IWP: IWP: Bunk Choice Select
      #This script allows WebD users to select bunkmates for the coming summer.
      #List All Chosen Names
      Set Variable [ $BR_List; Value:List ( BRE__BUNKSREQUEST_tog::Bunk Request Choice 1;BRE__BUNKSREQUEST_tog::Bunk Request
      Choice 2;BRE__BUNKSREQUEST_tog::Bunk Request Choice 3;BRE__BUNKSREQUEST_tog::Bunk Request Choice 4 ) ]
      Set Variable [ $BunkRequest; Value:Agegroup_Names_List::Name_Full ]
      Set Variable [ $BR_Check; Value:FilterValues ( $BR_List ; $BunkRequest ) ]
      #IF check to see if the names has already been selected
      If [ $BunkRequest = $BR_Check ]
      Show Custom Dialog [ Title: "No Duplicates"; Message: "You have already chosen this person. Please give us FOUR differnt names!
      Thanks!"; Default Button: “OK”, Commit: “Yes” ]
      Exit Script [ ]
      End If
       

      If [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 1 = "" ]
      Set Field [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 1; $BunkRequest ]
      Else If [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 2 = "" ]
      Set Field [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 2; $BunkRequest ]
      Else If [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 3 = "" ]
      Set Field [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 3; $BunkRequest ]
      Else If [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 4 = "" ]
      Set Field [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 4; $BunkRequest ]
      End If
      Commit Records/Requests
      [ Skip data entry validation; No dialog ]
       

    • By docasar
      Hello,
      I am still very amateur on Filemaker so i hope my question does make any sense.
      I am trying to write a script that would basically import order information from an email and convert it, first in a new account (if the customer does not exist) and later create a Sale Order. So far, I have managed to do that, but the problem i find is when trying to convert the sale order into an invoice. Since this order comes from our webshop when we receive the email means it is paid, so my aim is that when creating the invoice from the Sale order, this would be marked as paid and set the amount due to zero.
      This would sound a very easy task, but since our solution incorporates a payments module to manage the payment of an invoice, when i try to incorporate the payment entry within my script, there is when all the trouble starts. For some reason, it gets lost in its way when runnig the script and returns a partial payment all the time. The weirdest thing is thet if I run the script on debug mode, then all works perfectly, so my guess is that the issue may be related to the speed of the script.
      So, is there any recomendation as for where to put a pause script step so the script will work also when run automatically?
      I have tried every possible combination of long script, shorter with other scripts inside, perform script on server... and all the time something is wrong ;(
      Thanks a lot for any insight thst would help us move forward, since we have been trying to solve this for a week already.
       Best
      Luis
    • By Richmilnix
      For an inventory management database, I'd like my main screen to be able to accept pulls from three related databases:
      - Serialized (valuable tools, which I track and want back - the paintbrush);
      - Replenishable (cheap tools that I buy by the yard and if one gets left behind I don't care - the paint-mix sticks);
      - Perishable  (disposable tools that are left on the job site - the paint).
      These will handle their related requests differently. The serialized I'll be tracking properly to make sure we keep track; the latter two I'm looking for more like a system of 'tick marks' to help me know what we use on job sites.
      We print our barcodes. For ease of use, I'd like staff to scan into a single field in an interface that is smart enough to do the right thing based on a key digit in the barcode. So when I scan barcode 'S1234', my db knows to move it to the Serialized relation field; when I scan 'P1234,' it knows we're in Perishables.
      Looking for the elegant approach. My thought is that that central hot field (Scan_Here) will, when entered, store a variable and trigger a script built within the context of the related table, but I'm sometimes prone to reinventing wheels and doing stuff the long way, so I'm asking for suggestions / examples.
    • By JH Howland
      I have created an "opener" file called "OpenMP" that is located on the Windows Desktop.  Also, a global variable for the directory where the FMP14 files are located called "$$marinaDir" = "MarinaPro v17".
      When activated the launcher opens but does not open the target file using the following file path, "filewin:/C:/$$marinaDir/Marina.fmp12."  However if I substitute with the following, "filewin:/C:/MarinaPro v17/Marina.fmp12"; all is good.
      The script elements follow:
      #Create variable...
      Set Variable [$$marinaDir; Value: "MarinaPro v17"]
      #Start MarinaPro...
      Open File ["Marina"] (Marina File Path: filewin:/C:/$$marinaDir/Marina.fmp12)
      What am I missing?
    • By davidrichards
      I am having a tough time getting the set field by name script step to work and hoping someone can help me with this.
      I have a file of sales transactions over many years.  I have a related file for customers.  The customer file has counters for how many times a customer visits each year, how many suits, sportcoats, etc. they buy each year ( visits_2017, visits_2016, visits_2015, suit_count_2017, suit_count_2016, suit_count_2015 and so forth). I would like my script to evaluate the year of the transaction in sales and update the appropriate counter in customers.
      I have been unsuccessful in defining a variable and set field by name combination to accomplish this task.  Any recommendations?
  • Who Viewed the Topic

    12 members have viewed this topic:
    Edward Yuen  sbo  amerioca  Ron Cates  xochi  skingjack2  dubl  Lola  prosoft  NewBoard  vwgtiturbo  Lewis Stairs 
×
×
  • Create New...

Important Information

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