rbf_runTrigger()

Warning: Support for using this method with external objects (such as those mapped to external tables, to OpenEdge Service objects, or through a HDP connection) is a beta feature. This method is supported in production systems, except for external objects.

Purpose

This function sends AJAX request to run a trigger on selected record.

The current user must have Edit permission on the selected object type to run this API.

Syntax

rbf_runTrigger(objName, id, triggerId, checkCondition, callback, useLegacyDateFormat, options)

Parameters

objName

The integration name of the selected object definition

id

ID of the selected object record

triggerID

The integration name (string) or original ID (string) of trigger to run

checkCondition

If true, check trigger's condition formula before running trigger, otherwise ignore condition formula.

callback

A function to be called when AJAX request returns (optional). Will receive single parameter: true or false depending on whether trigger has actually ran.

useLegacyDateFormat

This only applies to Date and Date/Time fields in JSON output. When set to false, a date value is returned as a String. When set to true, a date value is returned as a Date object. Default value is true

options

options is a list where maximum of two name-value pairs set in a variable in the form {name1 : value1 , name2 : value2} can be configured. The possible names are runRecursions & rollbackOnFailure with the values true or false.

  • When the key runRecursions is set to true, it configures trigger to run recursively, assuming recursive properties are set on the trigger definition page. Default value is false.
  • When the key rollbackOnFailure is set to true, it configures trigger to revert the changes which was the part of execution enabling the user to perform the action again. Default value is false.
  • When the key runDelay is set with any value in milliseconds, the trigger is scheduled to run asynchronously with the given delay from the current time.
    • When skipped, delay timing from the trigger definition is considered.

    • Any value greater than 0, the trigger is scheduled to run asynchronously with the given delay from the current time.

    • Any values less than or equal 0, there is no delay timing.

  • When the key runAsJob is set to true, the trigger is scheduled to run as large job with an enhanced monitoring and cancellation capabilities. If false value, the trigger is not set to run as large job. See Run as Large Job, for more information.
    • When skipped, Run as Large Job from the trigger definition is considered.

Note: This API is supported in portals as well.

Example

Example 1:

If you want the system to send email when portal user clicks on particular link on your portal page do the following:

  1. Prepare an email template.
  2. Prepare a trigger to send email. This example uses the integration name sendEmail
  3. Make sure the Edit operation is allowed for either Portal User or API User.
  4. Prepare the following link:
    <a href='#' onclick='rbf_runTrigger(
           "myVisitor", {!#CURR_VISIT.id}, "sendEmail", false);'>Send Email</a>

    For OpenEdge or any external objects use the {!#UID} token in quotes:

    <a href='#' onclick='rbf_runTrigger("oeObject", {!#UID}, "sendEmail", false);'>Send Email</a>

Example 2:

Here, the trigger is invoked with the original id 13799 with the attributes runAsJob and runDelay is set to true and 60000ms respectively. Once the trigger delay time is elapsed, this is scheduled to run as a large job after 60 seconds from the current time.

<script>
function my_callback(val) 
{
	console.log(val);
	rbf_growlInfo("RunTriggerStatus RightNow->", val);
}
rbf_runTrigger("Student, 25445,13799, false,my_callback, false, {"runAsJob":true,"runDelay":60000});
</script>