Form Actions - On Success



Description

 

To perform any action when a record is submitted and stored in the database or when a record is deleted from the database, you need to write the on success script for a form. For example, send a mail to the team lead as soon as a feedback form is submitted, send a mail to the admin userid when a record is deleted.

 

By default, the message "Data Added/Edited Successfully" is displayed on successful submisson of form data. You can customize the success message by specifying the same in the success message string. Refer On success message for more information.

 

Syntax

On success action script - On add : The on success action script written inside the On Add block is invoked when a new record is added to the database. The user supplied data is already in the database when this script is run.

 

on  add
{
on success
{
// write deluge script to be executed when a new form data is persisted in the database

}
}

 

On success action script - On edit : The on success action script written inside the On Edit block is invoked when an existing record is updated and persisted in the database. The user supplied data is already in the database when this script is run.

 

on  edit
{
on success
{
//write deluge script to be executed when a new form data is persisted in the database

}
}

 

On success action script - On delete : The on success action script written inside the On Delete block is invoked when an existing record is deleted from the database. The record is removed from the database when this script is run.

 

on  delete
{
on success
{
//write deluge script to be executed when an existing record is deleted from the database

}
}

Example - Free Flow Scripting

    Send Mail : In the below given feedback form sample, a mail is sent when a new form data is persisted in the database.

     

    application "Feedback Application"
    {
        page "Feedback Application Home"
        {
            form  Send_Feedback
            {
                displayname  =  "Send Feedback"
    
                sender
                (
                    displayname = "From"
                    type  =  email
                )
    
                mail_subject
                (
                    displayname = "Subject"
                    type  =  text
                )
    
                category
                (
                    displayname = "Category"
                    type  =  radiobuttons
                    values  =  {General,   Usability,   Bug Report,   Feature Request}
                )
    
                comments
                (
                    displayname = "Comments"
                    type  =  textarea
                )
             
                status
                (
                    displayname = "Status"
                    type = picklist
                    values = {Open, Closed, In progress}
                    private = true             
                )
    
                on add
                {
                   on success
                   {
                      sendmail
                      (
                          To       : input.sender
                          Subject  : input.mail_subject
                          Message  : input.category+"<br>"+input.comments
                      )
                      success message "email sent";
                  } 
                }
    
            list  "Send_Feedback_view"
            {
                show  all  rows  from  Send_Feedback
                (
                    sender
                    mail_subject
                    category
                    comments
                )
                filters
                (
                    category
                )
            }
        }
    }

     

    Code Description

     

    In the above code, the sendmail function is added in the on success form action, where

     

    input.<fieldname> - replaces the value specified in the form for the fieldname to the To:, Subject:, and Message: entries.

Example - Using Script Builder

 

Refer the topic, Miscellaneous -> Success Message.

 

Related Links

 

FAQ's - Form Actions

On success message