Jump to content
sal88

Send email when record created over PHP

Recommended Posts

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

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

Thanks ggt667. My script is definitely activated via PHP however the send mail step is not working at all - either via plugin or the inbuilt send mail (smtp) script step. Am I missing a trick?

Share this post


Link to post
Share on other sites

I had a similar problem several years ago, and ended up just sending the mail in PHP, using a cron to check if there was a flag set in FM

Share this post


Link to post
Share on other sites

cron or php? Using cron you are usually better off using the system mailer.

Share this post


Link to post
Share on other sites

@ggt667 You're right, but I knew how to do in in PHP, and I learned how to run a PHP script with a cron. It's a kludge, I know, but it has worked fine for 8 years, so I never cleaned it up.

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 john renfrew
      This has long been an issue, I have no idea why it happens and it is making life quite difficult
      Win Server 2012 FMS 16 (current but this happens on other configurations)
      With ScriptMaster installed 
      run a script which resets the server ( SMReset) and then loads jars and functions return to you the result of SMGetRegisteredModules and show it in a dialog box
      run another script on the server which just returns to you the result of SMGetRegisteredModules and show it in a dialog box
       
      dialog 1 SHOWS the modules you installed
      dialog 2 is EMPTY
      fmsadmin restart fmse
      do the above again, same result
       
      this means you can not do a test on the server to see if a particular function is loaded before you want to use it.... in fact there is no test you can do to see if the ScriptMaster has fallen over as far as I can tell.
       
      Any solutions???
    • By jstewart30
      Running FMS 13 and trying to run a simple PHP page from my website to access a database, but I'm only getting a blank page.  Not sure if it's a port forwarding issue or a PHP issue, or something else.  If I put my .php file and the includes ("FileMaker.php" file and "FileMaker" folder from the FMS PHP .zip file) in the fmi-test folder on my FM server and access it locally (http://localhost/fmi-test/myphpfile.php), the PHP file works fine and returns data, so I don't think it has any inherent issues, and presumably my FMS is set up correctly.  Putting the same .php file and includes on my web server, though, results in a blank page only.  The includes are in the same directory as the php file itself.  Here's the php file (I've changed the IP address and database names to protect the innocent but they're correct):
       
      <?php
      error_reporting(E_ALL);
      ini_set('display_errors', 1);
      include_once('FileMaker.php');  /* have also used require, include, and require_once with no change */

      $fm = new FileMaker("MyDatabase", "http://myfilemakerserver:8888", "Admin", "");   /*no password*/
      $findCommand = $fm->newFindCommand("MyDatabase");
      $findCommand->addFindCriterion("Phone", "303-555-1234");
      $findCommand->setRange(0, 1);
      $result = $findCommand->execute();
      if (FileMaker::isError($result)) {
          echo($result->getMessage());
          return;
      }
      $record = $result->getFirstRecord();
      $name = $record->getField("Customer Name");
      $status = $record->getField("Status");
      echo("$name - $status");
      ?>
      Infuriatingly I get no errors or feedback, just a blank page when I run this file from my website (but again it works fine locally on the FM server machine). I've confirmed PHP is working on my website as I can do a simple phpinfo() file in the same directory and it runs fine and displays the PHP info.  If I direct a web browser to the same "http://myfilemakerserver:8888" (not the real address obviously, but it is port 8888) I get the "Filemaker Database Server Website" page, so the port forwarding seems to be correct.  I have port 8888 forwarding to port 80 of my FM Server.  I don't have port 443 forwarded to that machine as that's being used for another device on our network, but I assume if I'm not making "https" requests that it should work fine (but maybe that's my problem?).  
      I assume it's just something simple but I've been beating my head against a wall for the better part of the day on this.  Any help would be greatly appreciated.
    • By Martin Taylor
      Hi all experts (hopefully), I have just upgraded from FMS12 to FMS16. On the FMS12 server we are running a php solution. I have installed 16 onto a new server, uploaded all the databases (all successfully running) and have copied the php website to the new location on the 16 server. I can see the website from home (so I know the website is in the right place and the DNS s working) BUT I can't seem to connect to the database successfully. Any help would be much appreciated. Thanks in advance. 
      Oh, and it is accessed with https
    • By Tony Morosco
      Hello,
      I am trying to convert a custom web publishing site in php, from FM Server 12 to FM Server 15.    We've updated the Windows machine that hosts it (to a shared server on the recommendation of IT) and installed FM Server 15.  
      Direct opening of the existing scripts always yields 0 results, though the database hasn't changed.  
      Is there some setting, somewhere, that I am oblivious to?   I've consulted user's manuals, IIS settings, web postings, ...
      Attached is a copy of the website I am running.
      I can point you to the existing website, though I doubt it would be useful.  The beginning part of this website are script tracking errors.  I've been inserting them, trying to track down where this error is creeping up.  So please ignore.
      Please ask any additional questions, I am sure there are many.
      Cheers,
      Tony
       
       
      PublicPortal.zip
    • By JMart
      Hi gurus,
      I am sure I’m missing something simple, but for the life of me I can’t figure this out. I have a database with tickets. What I want is when a new ticket is created I want to see a popover (see attached) then I want the user to type in the top box and as they type I want to filter the list below (a portal) and once they client is shown they would select it and a ticker is created for the client. I sound a script and modified to fit my needs but can’t get it to work. Can someone stretch a helping hand?
      BTW the filtering is working but its not reflecting in the popover its reflecting on the layout.


  • Who Viewed the Topic

    1 member has viewed this topic:
    doughemi 
×

Important Information

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