sal88

Send email when record created over PHP

7 posts in this topic

Hi all

We have a web based tickets portal which creates new messages in our filemaker database - this is for customers' use. It does this using the PHP API (the website was developed by a third party). We would like the owners of tickets to be notified when the customer has added a message to one of the tickets that they are in charge of.

Is there a way for filemaker/filemaker server to trigger a 'send email' script when a new record is created via the web portal? Or would it be simpler for this action to occur on the web side?

Many thanks

Share this post


Link to post
Share on other sites

Posted (edited)

Hello

When your customers raise a new ticket some PHP is being executed which creates the corresponding record in your FileMaker database. 

The easiest thing to do to send your customer an email at this time would be to add a few lines of PHP code that runs a FileMaker script, which sends the email using the built-in SMTP features of FileMaker Server.

The PHP code would look something like :-
 

$appointmentID = "123456"; // you would get this from the context of your PHP to this point

$layoutName = 'SendEmailLayout'; // a valid layout name in your database which your script would run from the context of

$scriptName = 'SendEmailScript'; // the name of your FileMaker script that sends an email when on the layout named above

$arguementToPass = $appointmentID; // this will pass the correct appointment ID to FileMaker so that it emails the correct customer

$myScript = $fm->newPerformScriptCommand($layoutName,$scriptName,$arguementToPass); // this script will use the appointmentID to find the correct customer and email them

$result = $myScript->execute(); // this tells the web browser to run the FileMaker script

 

If you would like some local professional help with this PHP please DM me, we are a UK-based Platinum certified developer.

Edited by rwoods

Share this post


Link to post
Share on other sites

Posted (edited)

1 hour ago, sal88 said:

Is there a way for filemaker/filemaker server to trigger a 'send email' script when a new record is created via the web portal? Or would it be simpler for this action to occur on the web side?

I believe you are asking the wrong question, both FileMaker and the web can send email perfectly fine.

 

Is this a spread point for information? Then letting the submit button on the web may be the way to go, as mentioned by @rwoods

Is this a starting point for somebody to prepare something inside FileMaker?  Then letting the preparations be done first and click at the end of the preparations to trigger an email may give a more live feeling to the other pariticipants.

 

 

 

Edited by ggt667

Share this post


Link to post
Share on other sites

Thanks very much rwoods that looks to be the 'ticket', I will pass this on to the web developer but if there's any problems i'll be sure to contact you.

ggt667 I'm not sure what the difference between spread point and starting point is. The customer who is using the web portal is adding a query/information (as a new related record) to an existing support ticket. Our engineers can see within filemaker that the ticket has been updated (if they have their list of tickets on the screen), but it's more efficient if they can also be emailed a notification of the update as soon as it occurs. 

Share this post


Link to post
Share on other sites

So you are basically spreading the information to everybody no need for 1 person to verify the data and then inform the others. Then what @rwoods suggest is probably the better option.

Share this post


Link to post
Share on other sites

Understood, thanks @ggt667. Out of interest, is there a specific way for filemaker server to perform the script but without any such instruction from PHP? i.e. could it trigger when a new record has been created (of which the 'type' field would be set to 'web') and then perform the script? Or would this require a plugin or scheduled script that runs every minute, checking for newly created web originating records?

Share this post


Link to post
Share on other sites

You could write a script for server that is triggered every 5 mins by the server's script scheduler that checks if a record has a creation timestamp last 5 mins by your php script user, and if so issue an email.

Edited by ggt667

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • By randyinla
      Hi, I have a field called 'mytournament1'.  I also have a field called 'mytournament1played'.  With a form, I create the variable $tournament to bring 'mytournament1' to my results page.
      $tournament = $_GET['tournament'];
      I'd like to force the results page to search for the field 'mytournament1played' for each record by using the variable $tournament and combining the word 'played' or the variable $played.  
      $played = 'played';
      $tournamentplayed = $tournament . $played;
      $tournamentplayed2 = $record->getField('$tournamentplayed');
      (I want it to deliver)      $record->getField('mytournament1played');

      I know the 1st '$record->getField' line is wrong.  Can I combine 2 variables that spell out a database field name (mytournament1played) that can be used to call up a field in a search?  i.e.
      if ($tournamentplayed2!='1') {

      thanks in advance for your help!
       
    • By bwalsh
      Hi, I am relatively new to FileMaker. I am a PHP developer currently working on a project that involves the FMS custom web publishing PHP API. I was able to successfully connect using the API, but the connection is no longer working. The error message says only "Unable to open file". My research says that this could be due to the database file not being open, or to a permissions issue.

      I can see in the FMS admin console that the database file is open, with "normal" status. The FMWEBDIRECT and PHP columns both have full circles, indicating that the database should be accessible through the PHP API. Both the web server and the web publishing engine are on, with green checks, and PHP is activated.

      I am using the same username and password that worked previously. I checked again in the database security settings and confirmed that the username and password are still correct and that the user account has the "fmphp" privelege. What else should I look for?
      In the web publishing error log I see entries that say:
       
      127.0.0.1:63876 [USERNAME] - 802 563 "fmi/sml/fmresultset.xml?-db=[DB]&-lay=[LAYOUT]&-findany" Does the PHP API use the XML API? Also, here is the full var_dump() of the error object:

       
      object(FileMaker_Error)#6 (9) { ["_fm"]=> &object(FileMaker_Implementation)#2 (3) { ["V73ee434e"]=> array(9) { ["charset"]=> string(5) "UTF-8" ["locale"]=> string(2) "en" ["logLevel"]=> int(3) ["hostspec"]=> string(16) "http://127.0.0.1" ["recordClass"]=> string(16) "FileMaker_Record" ["prevalidate"]=> bool(false) ["database"]=> string(11) "DD_Personal" ["username"]=> string(14) "xxxx" ["password"]=> string(12) "xxxx" } ["Vea4b3413"]=> NULL ["V9a3dcbce"]=> NULL } ["error_message_prefix"]=> string(0) "" ["mode"]=> int(1) ["level"]=> int(1024) ["code"]=> string(3) "802" ["message"]=> NULL ["userinfo"]=> NULL ["backtrace"]=> array(7) { [0]=> array(6) { ["file"]=> string(90) "/Library/FileMaker Server/Web Publishing/publishing-engine/php/el capitan/lib/php/PEAR.php" ["line"]=> int(945) ["function"]=> string(11) "__construct" ["class"]=> string(10) "PEAR_Error" ["type"]=> string(2) "->" ["args"]=> array(5) { [0]=> NULL [1]=> string(3) "802" [2]=> NULL [3]=> NULL [4]=> NULL } } [1]=> array(7) { ["file"]=> string(101) "/Library/FileMaker Server/Web Publishing/publishing-engine/php/el capitan/lib/php/FileMaker/Error.php" ["line"]=> int(52) ["function"]=> string(10) "PEAR_Error" ["class"]=> string(10) "PEAR_Error" ["object"]=> *RECURSION* ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> NULL [1]=> string(3) "802" } } [2]=> array(7) { ["file"]=> string(129) "/Library/FileMaker Server/Web Publishing/publishing-engine/php/el capitan/lib/php/FileMaker/Implementation/Parser/FMResultSet.php" ["line"]=> int(48) ["function"]=> string(15) "FileMaker_Error" ["class"]=> string(15) "FileMaker_Error" ["object"]=> *RECURSION* ["type"]=> string(2) "->" ["args"]=> array(3) { [0]=> &object(FileMaker_Implementation)#2 (3) { ["V73ee434e"]=> array(9) { ["charset"]=> string(5) "UTF-8" ["locale"]=> string(2) "en" ["logLevel"]=> int(3) ["hostspec"]=> string(16) "http://127.0.0.1" ["recordClass"]=> string(16) "FileMaker_Record" ["prevalidate"]=> bool(false) ["database"]=> string(11) "DD_Personal" ["username"]=> string(14) "xxxx" ["password"]=> string(12) "xxxx" } ["Vea4b3413"]=> NULL ["V9a3dcbce"]=> NULL } [1]=> NULL [2]=> string(3) "802" } } [3]=> array(7) { ["file"]=> string(122) "/Library/FileMaker Server/Web Publishing/publishing-engine/php/el capitan/lib/php/FileMaker/Implementation/CommandImpl.php" ["line"]=> int(84) ["function"]=> string(5) "parse" ["class"]=> string(28) "FileMaker_Parser_FMResultSet" ["object"]=> object(FileMaker_Parser_FMResultSet)#5 (17) { ["Vcb5e100e"]=> string(3) "802" ["Vf5bf48aa"]=> array(3) { ["build"]=> string(10) "10/27/2016" ["name"]=> string(31) "FileMaker Web Publishing Engine" ["version"]=> string(10) "15.0.3.308" } ["V1ea7e575"]=> array(7) { ["database"]=> string(0) "" ["date-format"]=> string(0) "" ["layout"]=> string(0) "" ["table"]=> string(0) "" ["time-format"]=> string(0) "" ["timestamp-format"]=> string(0) "" ["total-count"]=> string(1) "0" } ["V9f81f3c0"]=> array(0) { } ["Vaae0d98d"]=> array(2) { ["count"]=> string(1) "0" ["fetch-size"]=> string(1) "0" } ["Vae581270"]=> array(0) { } ["V6e52c40b"]=> array(0) { } ["Ve13f1c92"]=> NULL ["V43432a31"]=> NULL ["V51bc3e3b"]=> NULL ["V26005321"]=> NULL ["V6468d939"]=> NULL ["_fm"]=> &object(FileMaker_Implementation)#2 (3) { ["V73ee434e"]=> array(9) { ["charset"]=> string(5) "UTF-8" ["locale"]=> string(2) "en" ["logLevel"]=> int(3) ["hostspec"]=> string(16) "http://127.0.0.1" ["recordClass"]=> string(16) "FileMaker_Record" ["prevalidate"]=> bool(false) ["database"]=> string(11) "DD_Personal" ["username"]=> string(14) "xxxx" ["password"]=> string(12) "xxxx" } ["Vea4b3413"]=> NULL ["V9a3dcbce"]=> NULL } ["V5431b8d4"]=> resource(28) of type (Unknown) ["V6de51026"]=> bool(false) ["_result"]=> NULL ["_layout"]=> NULL } ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(563) "" } } [4]=> array(7) { ["file"]=> string(130) "/Library/FileMaker Server/Web Publishing/publishing-engine/php/el capitan/lib/php/FileMaker/Implementation/Command/FindAnyImpl.php" ["line"]=> int(17) ["function"]=> string(10) "_getResult" ["class"]=> string(32) "FileMaker_Command_Implementation" ["object"]=> object(FileMaker_Command_FindAny_Implementation)#4 (19) { ["_findCriteria"]=> array(0) { } ["Vd65662c5"]=> array(0) { } ["Va9136a07"]=> array(0) { } ["Vf951bdce"]=> NULL ["V83f28691"]=> NULL ["V85fd701e"]=> NULL ["V6da136ea"]=> NULL ["V568aa2ec"]=> NULL ["_fm"]=> &object(FileMaker_Implementation)#2 (3) { ["V73ee434e"]=> array(9) { ["charset"]=> string(5) "UTF-8" ["locale"]=> string(2) "en" ["logLevel"]=> int(3) ["hostspec"]=> string(16) "http://127.0.0.1" ["recordClass"]=> string(16) "FileMaker_Record" ["prevalidate"]=> bool(false) ["database"]=> string(11) "DD_Personal" ["username"]=> string(14) "xxxx" ["password"]=> string(12) "xxxx" } ["Vea4b3413"]=> NULL ["V9a3dcbce"]=> NULL } ["_layout"]=> string(23) "BW Newsletter2Go Import" ["V7a2db0ea"]=> NULL ["_script"]=> NULL ["_scriptParams"]=> NULL ["_preReqScript"]=> NULL ["_preReqScriptParams"]=> NULL ["_preSortScript"]=> NULL ["_preSortScriptParams"]=> NULL ["V0b9a204c"]=> string(16) "FileMaker_Record" ["_recordId"]=> NULL } ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(563) "" } } [5]=> array(7) { ["file"]=> string(103) "/Library/FileMaker Server/Web Publishing/publishing-engine/php/el capitan/lib/php/FileMaker/Command.php" ["line"]=> int(137) ["function"]=> string(7) "execute" ["class"]=> string(40) "FileMaker_Command_FindAny_Implementation" ["object"]=> object(FileMaker_Command_FindAny_Implementation)#4 (19) { ["_findCriteria"]=> array(0) { } ["Vd65662c5"]=> array(0) { } ["Va9136a07"]=> array(0) { } ["Vf951bdce"]=> NULL ["V83f28691"]=> NULL ["V85fd701e"]=> NULL ["V6da136ea"]=> NULL ["V568aa2ec"]=> NULL ["_fm"]=> &object(FileMaker_Implementation)#2 (3) { ["V73ee434e"]=> array(9) { ["charset"]=> string(5) "UTF-8" ["locale"]=> string(2) "en" ["logLevel"]=> int(3) ["hostspec"]=> string(16) "http://127.0.0.1" ["recordClass"]=> string(16) "FileMaker_Record" ["prevalidate"]=> bool(false) ["database"]=> string(11) "DD_Personal" ["username"]=> string(14) "xxxx" ["password"]=> string(12) "xxxx" } ["Vea4b3413"]=> NULL ["V9a3dcbce"]=> NULL } ["_layout"]=> string(23) "BW Newsletter2Go Import" ["V7a2db0ea"]=> NULL ["_script"]=> NULL ["_scriptParams"]=> NULL ["_preReqScript"]=> NULL ["_preReqScriptParams"]=> NULL ["_preSortScript"]=> NULL ["_preSortScriptParams"]=> NULL ["V0b9a204c"]=> string(16) "FileMaker_Record" ["_recordId"]=> NULL } ["type"]=> string(2) "->" ["args"]=> array(0) { } } [6]=> array(7) { ["file"]=> string(64) "/Library/FileMaker Server/HTTPServer/htdocs/newsletter/index.php" ["line"]=> int(32) ["function"]=> string(7) "execute" ["class"]=> string(17) "FileMaker_Command" ["object"]=> object(FileMaker_Command_FindAny)#3 (1) { ["_impl"]=> object(FileMaker_Command_FindAny_Implementation)#4 (19) { ["_findCriteria"]=> array(0) { } ["Vd65662c5"]=> array(0) { } ["Va9136a07"]=> array(0) { } ["Vf951bdce"]=> NULL ["V83f28691"]=> NULL ["V85fd701e"]=> NULL ["V6da136ea"]=> NULL ["V568aa2ec"]=> NULL ["_fm"]=> &object(FileMaker_Implementation)#2 (3) { ["V73ee434e"]=> array(9) { ["charset"]=> string(5) "UTF-8" ["locale"]=> string(2) "en" ["logLevel"]=> int(3) ["hostspec"]=> string(16) "http://127.0.0.1" ["recordClass"]=> string(16) "FileMaker_Record" ["prevalidate"]=> bool(false) ["database"]=> string(11) "DD_Personal" ["username"]=> string(14) "xxxx" ["password"]=> string(12) "xxxx" } ["Vea4b3413"]=> NULL ["V9a3dcbce"]=> NULL } ["_layout"]=> string(23) "BW Newsletter2Go Import" ["V7a2db0ea"]=> NULL ["_script"]=> NULL ["_scriptParams"]=> NULL ["_preReqScript"]=> NULL ["_preReqScriptParams"]=> NULL ["_preSortScript"]=> NULL ["_preSortScriptParams"]=> NULL ["V0b9a204c"]=> string(16) "FileMaker_Record" ["_recordId"]=> NULL } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } ["callback"]=> NULL } Any help would be much appreciated!
    • By capsprojectos
      Hello,

      I have more than 10k executable files, each EXE export data to a single table, inside of an unique MySQL.

      I created a FM database to manage all data (ODBC), but I didn’t solve how to trigger a script from an external EXE, without looping for new data each minute.

       
      Questions:
      #01: There is way to trigger a script in an open database, without looping ?

      #02: Runtime solutions can be used with parameters?
      My best idea, at this time, is to create a runtime solution and a relationship, and call it from the EXE.  I do think is a "stupid idea" and there must be clever solutions out there.
       
      Thanks for all


       
      INFO: I am using windows 10 | FM Pro 15
    • By Bailey Kessing
      I am running a server script periodically (every hour lets say) which does some database maintenance, uploads some files, etc. I do this on a number of Filemaker Servers (latest server version running on Windows machines) without problems…except for one server. On this server I use scriptmaster to up load some large files into containers as they are generated from scientific instruments. The problem is that the server runs seems to run out of RAM memory after a "few" days. I think this is the only thing that this server does differently than the other 4 servers and feel that this is the problem. My question is…is there a way to "flush" memory used by the plugin or by the FM server. Has anyone else experienced something similar or am I barking up the wrong tree? Thanks. 
    • By charmcello
      I am tasked with troubleshooting a web registration form that queries a Filemaker Pro v12 database via a Filemaker PHP API.
      The web form had been running well for a couple of months after major revision, when all of a sudden:
      All dropdowns are empty All radio buttons are missing These symptoms appear to be browser-independent. The appearance of these symptoms is mysterious:
      Nobody has modified the PHP code for the web form - I've done a compare with a backup done at the time when the web form was not broken and it is identical to what is currently on the server.  The Filemaker Pro layout that the web form is querying is just fine - all the value lists for the dropdowns and radio buttons are present. I've created a stripped-down version of the web form: https://campmeetings.cccsda.org/test_form.php and I've also attached the php source code file.
      The date and record fields are populating correctly. Notice the empty dropdown list after "Church I attend."
      Could this be caused by an incompatibility between the FMP PHP API and PHP libraries on the server? Perhaps due to a PHP update on the server? Any ideas how to troubleshoot this? 
      test_form.php