Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

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

  • Author

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

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.

  • Author

It's going to be hard to work out what field is going to be the latest field that is entered...

 

Do you think the php script will add them in order??

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

  • Author

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

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).

:iagree:

  • Author

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?

  • Author

Howdy Guys,

 

Has anyone got any information on the above?

 

Thanks,

Scott

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 ...

  • Author

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

  • Author

Anyone?

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.  

  • Author

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

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?

  • Author

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

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.

  • Author

OK Thanks for the reply.

So if I run it straight after record->commit() will it only run on that last record it has created?

 

Thanks,

Scott
 

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.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.