TriggerExternalEvent Method

Triggers a custom Newlook event which can be handled in Smartframe.

System.TriggerExternalEvent(Name, Value)

Client support

   Newlook Smartclient only.

Version Support

Introduced in version 11.0.6.

Parameters

Name - (String, Required)

A string that is used to identify the event.

Value - (Value, Required)

This parameter can contain any primitive value (string, number, datetime etc.) or a structure.

Use

The Smartframe Newlook Control supports various events that can be used to update a Smartframe template. However, these events may not be fine-grained enough to provide the level of notification required by your template. This method allows you to trigger a custom event when, and where, you need it.

When the System.TriggerExternalEvent method is called it will generate an associated JavaScript event called 'onExternalEvent' within Smartframe.

The JavaScript event consists of a single argument: a JavaScript object with the following parameters:

Name

Type

Comments

SessionName

String

The name of the Newlook session that triggered the event. (Introduced in Version 11.1.)

EventName

String

Name of the event. The name parameter of the 'TriggerExternalEvent' method.

EventValue

Value

Value of the event. The value parameter of the 'TriggerExternalEvent' method. If the 'value' parameter is a structure then it will be converted to a native JavaScript object with properties matching the original structure.

BE AWARE:

Newlook form and/or control events cannot be triggered by this method.

GOOD TO KNOW:

The events triggered by TriggerExternalEvent can only be consumed by Smartframe. If you want to trigger events that can be consumed by both Smartframe and another session, consider using the TriggerCustomEvent Method.

EXAMPLES

This is an example of the TriggerExternalEvent call from a script in the Newlook solution:

JSCRIPT

var date = new Date();

 

System.TriggerExternalEvent(

"Timer",

{

   "Screen": App.ActiveForm.Title,

   "Year": date.getYear(),

   "Month": date.getMonth(),

   "Day": date.getDay(),

   "Hour": date.getHours(),

   "Minute": date.getMinutes(),

   "Second": date.getSeconds()

}

);

 

 

The following is an example of the Javascript 'OnExternalCallback' from within the Smartframe template:

JAVASCRIPT

var newlookRuntime = new Newlook(newlook);

 

...

 

 

newlookRuntime.onExternalEvent = function (args) {

 

// Filter by event name

switch(args.EventName){

 

   // Handle 'Timer' event fired in Newlook script

   case "Timer":

 

      // Get the values from the event argument

      var screenName = args.EventValue.Screen;

      var year = args.EventValue.Year;

 

      // Convert object to a JSON string

      var stringify = JSON.stringify(args.EventValue);

 

      // Do something with values.

 

      break;

   case "OtherEvent":

 

      // Add code to handle event

 

      break;

   default:

 

      // Default handling

}

}

See Also

Smartframe OnClosing event | Smartframe Newlook Control API | TriggerCustomEvent Method | Working with sessions

Applies To

System object


© 2004-2021 looksoftware. All rights reserved.