Jump to content

script parameter not getting passed...php


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

Recommended Posts

Can someone tell us what we are doing wrong here. Cannot get the scriptparameter to pass from php to filemaker. The code seems so simple...using php5, server 8v4.

Here is the script:

go to layout (layout name)

new record/request

set field (field_name; get(Scriptparameter))

Here is the php code:

$scriptcommand=&$fm->newperformscriptcommand('layout_name', 'script_name','script_param');

The script executes with no errors but the parameter always comes up empty in filemaker. Is there any permission/setting that would not allow filemaker to receive script parameters?

Link to comment
Share on other sites

Try tacking this on the end just to make sure there are no errors:

$scriptcommand=$fm->newperformscriptcommand('layout_name', 'script_name','script_param');

$scriptcommand->execute();



if( FileMaker::isError($scriptcommand) ) {

echo $scriptcommand->getMessage();

}

Link to comment
Share on other sites

Yeah, we're doing that already. The script executes cleanly with no errors. If we substitute a string literal (e.g., 'November') for the 'Get(ScriptParameter)', everything works as expected. We've isolated the problem to the parameter pass.

Link to comment
Share on other sites

  • Newbies

Could there be something problematic about the value that you are passing back to FileMaker -- some sort of character encoding issue, perhaps?

I am guessing that in your actual PHP code the final parameter to newperformscriptcommand() is a variable reference. For testing purposes, what about setting that variable to something trivial (e.g. 'abc') immediately before the call to newperformscriptcommand()? If it works like that, you will know that the problem lies with the content of the parameter, rather than the coding.

Link to comment
Share on other sites

Okay, you're right... script parameters never seem to be passed via cwp, whether you do newPerformScriptCommand() or setScript...

I had to come up with something today as a script requiring the addition of around 30 records was taking around 30 seconds.. wayyyy to long.

I created a new table with one field - naturally also a layout. The table and layout are called cwp_scriptParams, and the field called scriptParameter.


$script = $connection->newAddCommand('cwp_scriptParams',array("scriptParameter"=>$parameter));

$script-> setScript('myScript');

$result = $script->execute();





and the script in fm called 'myScript' looks something like this:





Set Variable[$param ; cwp_scriptParams::scriptParameter ]

Delete Record[]

Go To Layout[ required layout ]

#Then do rest of script using $param to address the  script parameter

Now my records take around a second to get added :B

HTH

Link to comment
Share on other sites

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