Solved

How to Select Hosted FM Database from VB

Posted on 2014-02-20
13
532 Views
Last Modified: 2014-03-03
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

0
Comment
Question by:jwleys
  • 4
  • 3
  • 3
  • +1
13 Comments
 
LVL 24

Expert Comment

by:Will Loving
ID: 39875137
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
 

Author Comment

by:jwleys
ID: 39875315
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
 
LVL 24

Expert Comment

by:Will Loving
ID: 39875753
Well, as I say, I have no experience with VB, so perhaps someone else will respond...
0
 

Author Comment

by:jwleys
ID: 39875852
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
 

Author Comment

by:jwleys
ID: 39875857
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 24

Expert Comment

by:Will Loving
ID: 39875899
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
 
LVL 1

Accepted Solution

by:
grnassar earned 500 total points
ID: 39876970
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39876983
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
 
LVL 1

Assisted Solution

by:grnassar
grnassar earned 500 total points
ID: 39877451
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
 
LVL 1

Expert Comment

by:grnassar
ID: 39877467
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
 

Author Comment

by:jwleys
ID: 39901422
Cool, thanks. I'll look into the launcher idea as an additional work-around.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Creating and Managing Databases with phpMyAdmin in cPanel.
Read about achieving the basic levels of HRIS security in the workplace.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now