How to Select Hosted FM Database from VB

I want to call a FileMaker script from VB.Net. The database is always open (remote connection to a hosted version). How do I assign the open database to a variable? I cannot open the database, since it is already open.

Same code as follows:

Set objFM = WScript.CreateObject("FMPRO.Application")
objFM.Visible = True
Set objFMfile = [*something here to assign current active database*]
objFMfile.DoFMScript ("PDF_check_status")

Open in new window

Jeremy LeysTechnical LeadAsked:
Who is Participating?
 
grnassarCommented:
How about a .fmp12 "launcher" file, with a OnFirstWindowOpen script trigger that runs a local script that does nothing but Perform Script the script in the hosted file and then Close File[current file]?

So, in other words, same principle as the "opener" file idea in the FM knowledgebase:

http://help.filemaker.com/app/answers/detail/a_id/5296/~/how-to-create-a-way-to-quickly-open-networked-files-in-filemaker-pro

but instead of it opening the networked file, it performs a script in the already-opened file?  You can then "open" the default-closed launcher file, and it returns to closed by itself once the script completes.
0
 
Will LovingPresidentCommented:
I have no knowledge of VB, but FileMaker does include the ability to call scripts via a URL. For example: FMP://192.168.10.0/Clients.fmp12?script=ListClients

See the following FileMaker Knowledgebase article for more information on how to do this:

https://www.filemaker.com/12help/html/sharing_data.16.7.html
0
 
Jeremy LeysTechnical LeadAuthor Commented:
Thanks for the suggestion. I still need to call a FileMaker script from VB (or any other external script – I am open to suggestions). Using VB to call a URL to execute the script would be good, but that doesn't seem to be working either. I have tried the following:

NavigateWebURL("FMP://[username]:[password]@[database].fmp12?script=PDF_check_status", "default")

Open in new window


and

Dim myRequest As WebRequest = WebRequest.Create("FMP://[username]:[password]@[database].fmp12?script=PDF_check_status")

Open in new window


and

Process.Start("FMP://[username]:[password]@[database].fmp12?script=PDF_check_status")

Open in new window


I have tested a URL call from within FileMaker, so I know the path is correct. I just need to get it working from an external source.

Many thanks!
0
Network Scalability - Handle Complex Environments

Monitor your entire network from a single platform. Free 30 Day Trial Now!

 
Will LovingPresidentCommented:
Well, as I say, I have no experience with VB, so perhaps someone else will respond...
0
 
Jeremy LeysTechnical LeadAuthor Commented:
Thanks for your help, doesn't have to be VB (stuck on a Windows server so can't use Apple Script), I tried doing a URL call from Filemaker but have found that Filemaker 13 Server doesn't have the ability to call scripts via a URL. I can do this easily from the client application but not the server.

Thank you for your time and input it is much appreciated.
0
 
Jeremy LeysTechnical LeadAuthor Commented:
Unfortunately have to use the server as the server is used to render a WebDirect website which the users will be interacting with. So user interaction is via browser not a Filemaker client application.
0
 
Will LovingPresidentCommented:
If you are using WebDirect, why not just access the database directly within a browser window using the URL for the server instead of trying to call a script?  A simple <a href= with the proper URL string should open the database in a window or a frame.
0
 
GrahamSkanRetiredCommented:
In legacy VB, you can get the application object (if it is COM-enabled) with GetObject
Set objFM = GetObject(,"FMPRO.Application")

Open in new window

0
 
grnassarCommented:
I still like the "launcher" solution, as IMHO FileMaker can be a little squirrely with filesystem scripting and works best with its native scripts.  That being said, since this has now been moved to the VBScript zone:

Your code looks fine.  (You don't need the application to be visible - FM responds fine from the background.)

All it seems you're missing is how to assign the right document to your objFMFile variable.

The Documents collection in the application object holds all your open files.  Documents has an Item() property that you can pass the file name as a string (FM's docs say full pathname, but since yours is hosted I think just the file name is needed; not even sure if it needs the extension -- may want to try it both ways) and it will give you the particular Document object for that specific file.

If for some reason that doesn't work, you may just have to iterate over the Documents collection looking at Document.FullName until you find the file you want.  But I don't think that'd be necessary in this case.
0
 
grnassarCommented:
I should've included this with the explanation above:

http://www.filemaker.com/help/html/create_script.12.13.html

That's from the FM13 help, but the actual objects, methods and properties available haven't changed since at least FM11 and probably since well before.
0
 
Jeremy LeysTechnical LeadAuthor Commented:
Cool, thanks. I'll look into the launcher idea as an additional work-around.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.