sal88

Send email when record created over PHP

11 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

Posted (edited)

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 Julio
      Hello,
      I have a weird issue that just started happening when I use the 'Print to PDF' script step in a loop.
      I have a script that passes through and prints out a set of pages. When I use the script Debugger and when I reach the spot I am having issues with, I can see, during the preview, that it is in the correct record; showing the correct page, but once it is done and saved as a PDF, it is showing the first record that was browsed.
       
      I have attached a snapshot of the script I am using.
      If you notice, I have it go to the layout First, Performs a Find based on a Variable - It finds the proper records.
      Then it goes to the first record, (for this example, lets say record # 36)
      Starts a loop and saves the record being browsed to a PDF. Then it moves on to the next record in the found set.
      The Custom Dialog which SHOULD show the next records ID, does not. It still shows record #36.
       
      I have no clue as to why. Even though as I go through each script step and I can visually confirm it is moving to the proper record in the FileMaker client, it does NOT save the proper Record.
       
      If I switch the option on the 'Save Record as PDF' from Current Record, to records being browsed, it saves the proper records to PDFs, but it duplicates them 3 times and does not set the proper page numbers.
       
      Attached is also the end result
      The Observ ID: should be 36, 37, 38 but all three pages stay at 36 showing the exact same record.
       
      Thank you all for your help.
       
       
       
       
       
       
       




    • By GisMo
      I have a php script that takes two PDF files and merges them into one file. I am using this in conjunction with the insert from URL script step. 
      The way the script works is it takes two PDFs in container fields and base64encode each files. Then, those two base 64 strings are POSTed via insert from URL.
      I've tested the script forwards and backwards and it does combine the PDF files reliably. The issue is when posting from FileMaker. What typically happens is the first page is combined twice and that's my resultant PDF. 
      My php script checks that both inputs are different and throws an error is they are identical. I don't get any errors there.
      Is there a way to POST a file from insert from URL?
    • By dysong3
      I have a number of scripts that have worked perfectly for years in previous versions of FileMaker, however in FMP 15 they causse FM to crash.  They only way I have found to avoid the crash is to use the debugger and to use the "step into" button.  That of course is a very cumbersome workaround. You can see one of the culprits below.  Anyone have any ideas what's wrong here?
       
       

    • By Jason Mundok
      I have a website that is displaying FileMaker data using the PHP API. Is there a way for the web site to display the basic text formatting from a FileMaker field? For example, a few words in the comments field are bold in FileMaker and I would like them to also be bold on the website. Thanks for any ideas.
    • 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!