AnsweredAssumed Answered

Filemaker/PHP execute script result

Question asked by dpistole on Apr 1, 2015
Latest reply on Jan 13, 2016 by user19752

Title

Filemaker/PHP execute script result

Your post

I have a PHP script that interacts with the Filemaker API (FM Server 13).

The idea is that a user clicks a a link on a webpage, which submits a request, PHP triggers a Filemaker script that generates a document, and then the user is redirected to a page where they can download the doc that was generated by filemaker.

As a side note, the script that is triggered performs another script using "Perform Script on Server", and that script generates the doc and returns the doc ID to the parent(originally triggered) script. This portion seems to be working OK. The doc is generated, the ID is returned, and I store the doc ID as part of a 'ScriptResult' record.

I cannot figure out how to get the doc ID back into PHP. In PHP the result object that returns from the execute script command usually has two records. One being the newly created Script Record, and the other being some random 'ScriptResult' record. If I comment out the part that generates the new 'ScriptResult' record, I still get some random older 'ScriptResult' record for some reason ( I cannot figure this out, and it seems random as it changes every request and does not appear to be incremental or anything. )

A simplified version of the filemaker script looks like...

Set Variable [$params, Value(Get(ScriptParameter))]
Perform Script on Server["generate_doc" from file: "FM_File"; Parameter: $params]
Set Variable [$result; Value:Get(ScriptResult)]
New Record/Request
Set Field[scriptResult::docID; $result]
Commit Records/Requests[]


..and what I get back is a Result object, with multiple records, one of which is the ScriptResult I've created, and the other seems to be some random ScriptResult. I only want the newly created ScriptResult back, so that I can pull the document ID field from it.

Any input is appreciated

http://stackoverflow.com/questions/29402803/filemaker-php-execute-script-and-return-result

Outcomes