Creator Help

Form Actions - On success

Overview

On Success script in Deluge is used to execute script actions when a new record is successfully submitted to the database or when an existing record is updated or deleted from the database. For example, send a mail to the team lead as soon as a feedback is submitted, send a mail to the admin userid when a record is deleted or open a new page when a record is submitted.

The "On Success" script associated with a form will get triggered only in the following cases:

  • When data is added from the browser
  • When data is added through API
  • When data is added through Import
  • When data is added through email data feature.

So, if the "InsertRecord task" is invoked from onClick action of stateless form, the "onSuccess" action associated with the form will not be executed.

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 on customizing the success message.

Syntax

Form Actions - On Add - On Success: The On Success script added to the Form Actions -> 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. 

The Form definition of the script will be displayed in the Form Definition -> With Action block of the Script Builder, in the format given below. 

actions
{
on add
{
Submit
(
type = submit
displayname = "Submit"
on success
{
// write deluge script to be executed when a new form data is persisted in the database
.......
.......
}
)
}

Form Actions - On Edit - On Success : The on success script added to the  Form Actions -> 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.

The Form definition of the script will be displayed in the Form Definition -> With Action block of the Script Builder, in the format given below. 

actions
{
on edit
{
update
(
type = submit
displayname = "Update"
on success
{
//write deluge script to be executed when a new form data is persisted in the database
..................
}
)
}
}

If you edit any record at https://creator.zoho.com/sampleapps/script-actions/#View:On_Success_View and click on update, you will be taken to https://creator.zoho.com/marketplace in a new window. We have written an OpenUrl task On Edit ->On Success script section. The script is mentioned below:

openUrl("https://creator.zoho.com/marketplace","New window") ;

Form Actions - On Delete - On Success : The on success action script added to the Form Actions -> 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.

The Form definition of the script will be displayed in the Form Definition -> With Action block of the Script Builder, in the format given below. 

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

Steps to add the script

Refer the topic Using Script Builder for steps to add the script.

Example

In the sample Form at https://creator.zoho.com/sampleapps/script-actions/#Form:On_Success we have written a script  to open the URL https://creator.zoho.com/marketplace in a new window after you click on submit.

The script is added to the On Add -> On Success block of the Form. The script uses the OpenUrl task to redirect the form to a specified URL, on form submit.

How to copy the application to your account?

Refer the topic "Application Backup".

How to reach the On Add ->On Success section?

  1. Edit the application (by clicking on Edit this application link, or from the home page, click on the Edit link next to your application)
  2. Select your Form from the Forms tab. 
  3. Click on Form Settings icon in the Form Header and select WorkFlow - On Add - Actions on Success.  This will take you to the On Add -> On Success section of your Form’s script. You can drag and drop the deluge tasks from the left side to write your business logic there.  If you have sample code that you want to directly copy-paste to the script builder or type the code directly, use the Free-flow scripting option displayed on the top-right corner of the builder.

Top