Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Hello All,

 

I have a php script that import data from our web form straight into our filemaker...

 

I'm just working on a mobile number validation script that I want to run once all the data base been imported, is the only way of doing it once the last field has been populated from the php script or is there another way of filemaker knowing once the import has been completed.

 

Cheers guys.

Scott

Posted

What is the validation?  Can it be done with an auto-entered calculation attached to the field?

Posted

Thanks for the reply... Unfortuntaley not it has to call an API and then import the XML result back into FileMaker...

Do you think I could run it on RecordCommit?

 

Thanks,

Scott

Posted

Without a lot of testing, the safest way would be to use your original idea to call the FM script at the end of the php script.

Posted

Hard to tell without knowing what's in the php script or the FM schema.

Posted

Hey,

 

I've tried adding the script on the field that I think will be last populated but it just seems to ignore the trigger script... I've also tried adding it to the layout trigger scripts but still no luck..

 

Any other idea? Do you think it's because the user "php" has the permissions of "read only"?

 

Thanks,

Scott

Posted

If the field is read-only for user "php", it won't change from the php script, so no trigger.

 

Again, it would be a lot easier to help you if we could see the scripts (both php and FM).

Posted

Hello, sorry for the slow reply.

 

This is the script that I've got set to trigger when one of the field changes...

 

mobile-validation_zps37f28fc9.png

 

and this is the PHP script that adds the new record from the website.


<?php

ob_start();

require_once("./FileMaker.php");

$fm = new FileMaker('1 Private 2005', '1.1.1.1');

$keys = array(

'VoucherCode',

'Title',

'First Name',

'LastName',

'EMailAddress',

'TelNoMobileorHome'

);


global $keys;

$result = array();

$record = $fm->createRecord('Import');

foreach ($keys as $fieldname) {

        $value = null;

        if (!strpos($fieldname, " ")) {

                $value = $_POST[$fieldname];

        } else {

                $value = $_POST[str_replace(" ", "_", $fieldname)];

        }

        $record->setField($fieldname, $value);

}



$result = $record->commit();


print "<p>finished!";

ob_end_flush();

?>

Can anyone think of a way of doing this?

Posted

I am very weary this morning, if I misunderstood(sorry) however,I think 1 of 4  things may work.

 

1) after the form is submitted , use FM to generate the corresponding result page based on a calculation field <- based on number validation true or false

 

2) you could  run a server side script in Fm to check for last updated record and run a script and this could run every minute or whatever you set it for,  this would have obvious    

     problems.  in  your case.. time I think would be your problem as well as resources may be an issue.

 

3) If all you are looking to do is validate a phone number can you simply use   a php script like this

$justNums = preg_replace("/[^0-9]/", '', $string);
if (strlen($justNums) == 11) $justNums = preg_replace("/^1/", '',$justNums);
if (strlen($justNums) == 10) $isPhoneNum = true;

 

4)  use IWP for the form instead of PHP

 

Just something to think about, I will revisit this after I get some rest ...

Posted

Thanks for the reply, I have answered your suggestions below:

 

1 - I don't think this will work after the PHP input has finished.

 

2 - The issue with this is a record probably changes every second within the office so this would work very well for us.

 

3 - We need to check that the number is actually valid not just a fake mobile number.

 

4 - I can't use IWP as it's coming from a data form.

 

Have you had any luck using this command thorough PHP:

 

//CREATE PERFORM SCRIPT COMMAND
$command = $fm->newPerformScriptCommand($layoutName, $scriptName, $scriptParameter);
 
//EXECUTE THE COMMAND
$result = $command->execute();

I would be able to call this after the script has finished...

Thanks,

 

Scott

Posted

Works fine for me.  (That's what I implied in post #4.  Sorry it wasn't clear.) What I'm not sure about is whether the php script waits for the FM script to complete, or goes charging on regardless.  If i's the last step in your php script, the question is moot.  

Posted

Howdy guys, I've just tried this now it doesn't seem to want to work... I've added the set trigger script when the "last field" exits but it doesn't run.

 

Do you think I could just run:

//CREATE PERFORM SCRIPT COMMAND
$command = $fm->newPerformScriptCommand($layoutName, $scriptName, $scriptParameter);
 
//EXECUTE THE COMMAND
$result = $command->execute();

After I have added all the data too the record?

 

Will it only run for that record that has just been added or will it run for all records in the database?

 

Thanks,

Scott

Posted

It will run for whatever records the FileMaker script tells it to run. 

 

It really would help if your questions were more specific. Are you using the newPerformScriptCommand in the php script, or are you using a script trigger in the FileMaker file?  Exactly HOW does it not "seem to want to work"?  Is the data actually getting into the FileMaker record from the php? The FM script has an Import Records command.  Isn't that covered by the php script?  Why don't you want to do the validation in php before importing it into FM and setting an invalid flag if not valid?

Posted

Sorry, was rushing when I was posting...

 

I am not using the newPerformScriptCommand I was just wondering if it would work better than the script trigger?

 

What I have done to test this is looked at the last field in PHP script and set a script trigger against that field in FileMaker, I have then watched the script debugger while in that layout to see if anything is called when the PHP script is submitted but nothing happens and the script doesn't run.

 

If it just isn't possible to run it like this I will have to put the validation on the php script side but I didn't really want to as it's a little slow...

 

Thanks,

Scott

Posted

I have php scripts that work fine using the newPerformScriptCommand() to run a FileMaker script.  The command should be after the record->commit() statement.

 

I have not used an output buffer for any of my php scripts which interact with a FileMaker database.  You might try commenting out the buffer statements to see if that makes a difference.

Posted

Not necessarily. You don't know what the found set is for the php "user".  I always do a find for the last record in the FM script just to be safe.

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