Jump to content
Server Maintenance This Week. ×

VBScript to write data to FM database?


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

Recommended Posts

  • Newbies

Hi everyone, new to FM and new to here.

We run a mixed installation of Mac and Windows computers in a Tiger server OD with a SAMBA domain.

My Mac engineer colleague has got ARD to put data about the Macs into a FM asset database, such as serial number, mac address etc...

I use a tool called BGINFO to do the same to an access database on a share on the server.

I have a vbscript logon script which maps drives and executes bginfo and does other things.

My question is.... how easy is it to add a bit of vbscript to take some WMI data and write it to fields in the FM asset table?

I would obviously have to query the database first to check if the workstation exists if not write a whole new record otherwise update the existing record.

Has anyone tried this and would be willing to share some sample code for me to work on?

What options do I need to check in filemaker to make sure the vbscript can connect?

Thanks

Paul

Link to comment
Share on other sites

This saved as a .vbs will look for a filemaker file, copy it to a local path, and execute a script.

'Creates Filemaker object

Set objFM = WScript.CreateObject ("FMPRO.Application")

'Creates File System Object

Set fs = CreateObject("Scripting.FileSystemObject")

'Check if the file exists

If fs.FileExists("C:local pathFM_File.fp7") then

'nothing

Else

'Copy File to Local Computer

 fs.CopyFile "network pathFM_File.fp7", "C:local pathFM_File.fp7"

 Wscript.Sleep 2000

End If

Set objFMfiles = objFM.Documents.Open("C:local pathFM_File.fp7","admin","") 'open FM file   (filename,username,password)

objFMfiles.DoFMScript ("Import") ' call this FM script

Wscript.Sleep 1000

WshShell.AppActivate "FileMaker Pro"

WScript.DisconnectObject(fs)

WScript.DisconnectObject(objFM)

WScript.Quit(1)

Couple of notes about doing this:

  • * You cannot open a shared filemaker file from a VBS script (you can connect to one) so if you are running the script before the target file is open you need to open a local file. (the script in the local file can execute a script in a shared file.)

    * You can only use vbs to execute a filemaker script. (so to get info into filemaker you need to import it)

    * There is a bug in the Filemaker Object model (do not use script folders in the filemaker file you are calling the script from, if you do, the vbs call for the script may call the wrong one.)

I hope this helps a little.

Allen

Link to comment
Share on other sites

* You can only use vbs to execute a filemaker script. (so to get info into filemaker you need to import it)

I was about to say so, but I'm usually on mac's where we have applescript pretty well fledged for such a task, but seemed to recall this.

However have I seen in Wim's site you can use the webviewer for returning stuff as well.

--sd

Link to comment
Share on other sites

A web viewer could be used to access data but to populate fields you would still need to run a Filemaker Script. (Import vs Scraping a Web page)

Not a bad idea, depending on your needs.

Link to comment
Share on other sites

Yes it is. The FM ActiveX model does not allow to set data into a field or even to pass a parameter to a script (which would solve some of this). I've been lobbying for this for ages now so please enter it as a suggestion on the FMI website.

You have a few more options:

- use a local ODBC connection to your FM file to push the data in

- use FileMaker Server Advanced and ODBC or XML into that.

HTH

Wim

Link to comment
Share on other sites

  • Newbies

We are running FM 9 Server Advanced so I thought I should just be able to query by ODBC remotely but I can't find anything on it.

I have tried to modify sample vbscripts which do ODBC stuff with MySQL and MSSQL but I juts get connection errors. When I have setup my xsan I'll come back to it.

Link to comment
Share on other sites

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