Jump to content
Server Maintenance This Week. ×

web request to run script that either finds existing or creates new record


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

Recommended Posts

I am experienced with both FileMaker and PHP, but I am new to the FileMaker PHP API, and I'm trying to find the easiest/best way to implement a sort of web service. I have a FileMaker script that currently does most of what I need, but I need to run it via the PHP API.

A remote server submits a single http request with several variables to the FM web server, including an ID number.

These values are stored in global fields in a FileMaker table. A FileMaker script then retrieves these values from the global fields, and searches the table for an existing record with the same ID number.

If there is no record with the same ID, a new record is created and populated with the submitted values. This single record is returned, including additional values that must be calculated by Filemaker.

If there is already an existing record with the same ID, the existing record is compared to the values submitted by the remote server to see how different they are. If the values are the same, or similar enough, then the record is considered a match. The values from the existing Filemaker record are returned.

If the ID is the same, but the differences in the other values exceed a certain threshold, then the record is not a match, and an error is returned.

The current script works by storing the remotely submitted values in global fields, then operating on those. But globals are session-specific, and from what I've seen, it doesn't look like the PHP API supports persistent sessions. Each transaction seems to be a separate session, so the globals are lost.

I've read that it's possible to have globals persist for an entire session with XML or XLSLT, but I suck at XML, and really can't afford the time to learn. Is there a simple way to make globals persist for an entire session with the PHP API?

Failing that, is there another simple way for me to use the existing script?

Link to comment
Share on other sites

You could create a globals table, one record, with a cartesian join to your main table(s). The fields in the globals table are normal text or number fields, not global. Now store the incoming data there, and it will persist as long as you please. You'll have to add housekeeping to your script to clear those values, if necessary.

Link to comment
Share on other sites

I thought about doing that, but the problem is that multiple requests might be processed simultaneously, so instead of a single record, I'd need to support multiple records, which would mean creating some sort of session ID and using that. I was hoping there was already a way to do this built into the API, but I guess there isn't.

I am thinking the easiest thing to do may be to just pass all the values as a single string script parameter and then parse them out in the script itself.

Link to comment
Share on other sites

  • 1 month later...

You can translate the logic of a FM script to a web version in PHP - to be honest, I rarely see the value in trying to make a FM script work via the web... I use FM as a data repository, with all of the logic built on the web side. Makes it transportable, and everything is in one place rather than spread across two platforms.

Link to comment
Share on other sites

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