Email only updated fields in a form

Email only updated fields in a form

If you have a long form that you use to update data in your database on a regular basis by someone other that a "Site Administrator" then you would probably want to send an email to the "Site Administrator" notifying them about the updated data.
divider

If you have a long form that you use to update data in your database on a regular basis by someone other than a "Site Administrator" then you would probably want to send an email to the "Site Administrator" notifying them about the updated data.

Question: How does the Site Administrator find the updated information in the email?

Answer: Only sent the updated information.

Follow the following steps to set this up.

  • Build your form, as usual, using nextensio form
  • Create an additional recordset listing the fields you want to check if they are updated.
  • Add your Send Email server behaviour
  • Add a "Custom Trigger" of type before and link it to the "Update Transaction"
    The content of the custom trigger might be something like this:
    ♦ First, we define a global variable that will be available across all functions
    ♦ Then we compare the new value with the old value
    ♦ If the values are different, update the global variable with whatever you want to display
    global $add_status;
    if ($tNG->getColumnValue('ad_status') != $tNG->getSavedValue('ad_status')) {
       $add_status = 'Status Changed to: '.$tNG->getColumnValue('ad_status').'<br />';
    }

    global $bal_due;
    if ($tNG->getColumnValue('ad_total_amount') != $tNG->getSavedValue('ad_total_amount')) {
      $bal_due = 'Balance Due: '.$tNG->getColumnValue('ad_total_amount').'<br />';
    }
  • Now set a condition for when the email needs to be sent, this condition checks the updated value against the original values and could look like this:
    I am checking if the ad_status or the ad_total_amount has been updated
{POST.ad_status} != {rs_old_data.ad_status} || {POST.ad_total_amount} != {rs_old_data.ad_total_amount}

Compose the email that needs to be sent and make sure the email format has been set to HTML
Your email might look something like this:

The following changes have been made.<br />
{GLOBALS.add_status}
{GLOBALS.bal_due}
End of updates

By adding html in the global variable in step 4 you avoid the need for html in your email and ending up with blank spaces

Written by:  - 15 Mar, 2011