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


  • Who Viewed the Topic

  • Similar Content

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


    • By Hoytopher
      Hi all,
      I'm an FM novice who has a functioning database, and I'm trying to add layers of functionality to it. One feature I'm trying to design is a script to search through a Gmail outbox with certain keywords.
      In URLs, "%" translates to "%25". Filemaker appears to do this automatically - In Gmail syntax, you need to write "in%3Asent" to have the Gmail search bar contain "in:sent" which searches my outbox. Here's my current code for Go to URL:
      This "%" bit translates to "%25". I've tried "\%", I've tried creating a string, x, then having it open x, but no matter what I cannot get "%" to show up as-is, it always translates to "%25". Is there any way around this? I've tried subtracting text, but I just can't seem to get it to work. Any bright ideas? I can't find an answer to this specific question of disabling URL string substitution.
    • By Agentshevy
      Hello everyone..
      Guess I have been away for a while. Not fully back though because I am not really engaged with computer tech stuff at the moment. However, I really stumbled across a problem earlier today while going through my email logs. I observed that a server script I had set up has not been attaching the Pdf file report as supposed to. It only delivers the message while leaving out the file attachment. I did test the script when I added it but what I did not test was the result when run by the server.
       
      Allow user Abort [Off]
      Commit Records/Requests [No dialog]
      Set Variable [$FileName;Value:"Summary"&".pdf"]
      Set Variable [$PDFPath;Value:Get(TemporaryPath) &".pdf"]
      Go to Layout ["Summary_Layout]
      Perform Script ["Print_Page_Setup"]
      Save Records as PDF [Restore;No dialog;"$PDFPath";Current record]
      Send Mail [Send via SMTP Server;No dialog]
       
      As at the time of my writing the script, I was not observant about server-side scripts. I did go back just recently to observe that the "Save Records as PDF" script step is not server compatible.
      Please, is there any work around on this? Much help is appreciated.
    • By Richard Carlton
       
      PHP VIDEO 2 - Process Walkthrough: https://youtu.be/yAQX0B9Hfyk
      PHP VIDEO 3 - Sample Code Review: https://youtu.be/9thUCa_q_eY
      Download Sample Code: http://fmstartingpoint.com/links/dl_proc.php?idc=CPN_S0067
      Live PHP Page to try out: http://fmstartingpoint.com/links/dl_proc.php?idc=CPN_R0068
      FileMaker CWP Guide: https://fmhelp.filemaker.com/docs/16/en/fms16_cwp_guide.pdf
×

Important Information

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