We have reset all users FileMaker related profile fields. Please take the opportunity to update your information,  this will provide background to members whom read your posts. Click here.

Jump to content
sal88

Send email when record created over PHP

Recommended Posts

sal88    0

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

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
ggt667    6
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
sal88    0

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

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

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

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

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

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

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

Share this post


Link to post
Share on other sites
doughemi    82

@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 jamescv7
      XML error: No memory at line 1
      Greetings, this error occurred when the Filemaker API cannot generate a bunch of records. (1000+ records and above)
      I've adjusted the time out settings for PHP even the memory limits.
      Is there any possible solution for this?
       
      According to some information, the error turns out that the 10 MB XML scripts is unchangeable.
      thanks.
    • By Keith McKay
      I have two tables, A & B, with similar fields.  I want to write a script that will search table B for records that match the fields that are entered in table A.  I am not sure how to do this.  Any suggestions?
    • By Ken d'Oronzio
      FREE fmREST.php – Simplifies & manages PHP connections to FileMaker 16’s REST-based Data API.
      The newly released FileMaker Server 16 now offers REST access to your FileMaker databases. There’s more about that how this impacts PHP developers here.
      The bottom line is that to use REST as part of your PHP solution, you would usually need to write a series of cURL functions and you would have to manually manage connecting & disconnecting from your server, and saving your tokens.
      This is a pain!
      We know it’s a pain, because we have spent the last several weeks rolling REST functionality into soSIMPLE Calendar.
      We created this class file to make it easier to manage dynamic REST sessions for soSIMPLE and our custom development. The goal of the class file was to help PHP developers start using the new REST engine as quickly and easily as possible.
      We’ll also be updating it with new features. If you’d like to add something to it, please let us know.
      What fmREST.php does:
      Makes every REST call available as a PHP function. Automatically login into FileMaker Server whenever you call any REST functions Saves your token for 15 minutes to reuse Checks for a broken or disconnected token and automatically reconnects and runs your function again Where do I get it?
      You can download the fmREST class file here.
    • By DreadDamsel
      Hi. I'm using FMPro 12 Advanced.
      Creating a database for our community centre and I need to add a membership number to contacts - but not all of them.
      I've created a separate table for Membership numbers (as not all contacts will have one, so serial numbers aren't appropriate).
      Each membership has a number of details fields.
      It's probably a REALLY logical and stupid problem I'm batting against - but I need to:
      Select a contact>go to their details>add a membership number (go to a floating window layout, enter the details to the serial-number-derived membership) and have the details including the number show up in a tab on the contact's details layout.
      I've created a relationship between my contacts file and my membership file via the Contact_ID>Contact_ID_fk and have played around with other relationships. 
      I've also created a simple script from a button on the Contacts membership tab to go to the Membership Layout window and create a new record. But it keeps creating a new record in the Contacts, not Membership - even though the relationship only has to create new records in the memberships side.
      I'm now running around in circles - please can anyone help me out here?????
    • 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.
       
       
       
       
       
       
       




×

Important Information

By using this site, you agree to our Guidelines.