On Event Extensions for Interview Buttons

An event extension for an interview button can take action in response to that event or possibly change behavior.

AddExtension pattern

The value of the event property passed into a custom search extension must be an event handler function with the required parameters, that will be invoked whenever the event occurs.

OraclePolicyAutomation.AddExtension({
    <event-extension-key>: function(event) {
        <code to respond to event> 
    }
});

The button events currently supported are listed in the table below.

Table 1. The custom event extensions
event-extension-key event object properties Description
onSubmit interview

Event handler invoked when the screen is submitted in response to the next/submit button being clicked or the enter key being pressed. The event object supports preventDefault() if the event handler wants to cancel the operation. It also contains:

  • interview - the interview object

Tip: An example of an event listener for the submit/next button is shown after this table.

onBack interview

Event handler invoked when the interview back button is pressed. The event object supports preventDefault() if the event handler wants to cancel the operation. It also contains:

  • interview - the interview object
onNavigated interview

Event handler invoked when the interview has navigated to another page. It also contains:

  • interview - the interview object
onChange interview, control, value

Event handler invoked when an input control is changed by the user. The event is notification only and cannot be canceled. It also contains:

  • interview - the interview object
  • control - the control object that is changing
  • value - the new value

Tip: An example of an event listener for an input change is shown after this table.

onRestart interview

Event handler invoked when the interview restart button is pressed. The event object supports preventDefault() if the event handler wants to cancel the operation. It also contains:

  • interview - the interview object
onExit interview

Event handler invoked when the interview exit button is pressed. The event object supports preventDefault() if the event handler wants to cancel the operation. It also contains:

  • interview - the interview object
onAddInstance interview, control, template

Event handler invoked when the add button is pressed on an entity collect control. The event object supports preventDefault() if the event handler wants to cancel the add operation. It also contains:

  • interview - the interview object
  • control - the control object for the entity collect
  • template - a blank object that can be filled with default values (similar to the new parameter for the addNewRow() method of the control object)
onRemoveInstance interview, control, rowIndex, entity, instance

Event handler invoked when the remove button is pressed on an entity collect control. The event object supports preventDefault() if the event handler wants to cancel the remove operation. It also contains:

  • interview - the interview object
  • control - the control object for the entity collect
  • rowIndex - the 0 based index of the row in the entity collect
  • entity - entity identifier for the entity that the row belongs to
  • instance - instance identifier identifying the instance for the row

Tip: An example of an event listener for the remove instance button is shown after this table.

An example of an event listener for the submit/next button is:

OraclePolicyAutomation.AddExtension({
    onSubmit: function(evt) {
        console.log("The submit button was pressed");
        evt.preventDefault();
    }
});

An example of an event listener for input change is:

OraclePolicyAutomation.AddExtension({
    onChange: function(evt) {
        var interview = evt.interview;
        var control = evt.control;
        if (control.getProperty("auto")) {
            interview.submit();
        }
    }
});

An example of an event listener for the remove instance button is:

OraclePolicyAutomation.AddExtension({
    onRemoveInstance: function(evt) {
        if (evt.control.getProperty("type") == "confirmation")
            if (!confirm("Are you sure you want to remove?"))
                evt.preventDefault();
    }
});