This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
WA EXECUTE JAVASCRIPT FUNCTION

WA EXECUTE JAVASCRIPT FUNCTION 


 

WA EXECUTE JAVASCRIPT FUNCTION ( {* ;} object ; jsFunction ; result|* {; param}{; param2 ; ... ; paramN} ) 
Parameter Type   Description
Operator in If specified, object is an object name (string) If omitted, object is a variable
object  Form object in Object name (if * is specified) or Variable (if * is omitted)
jsFunction  String in Name of JavaScript function to execute
result|*  Variable in * for a function with no result or
in Function result (if expected)
param  String, Number, Date, Object, Collection in Parameter(s) to pass to function

The WA EXECUTE JAVASCRIPT FUNCTION command executes, in the Web area designated by the * and object parameters, the JavaScript function jsFunction and optionally returns its result in the result parameter.

If the function does not return a result, pass * in the result parameter.

You can pass one or more parameters containing the parameters of the function in param.

The command supports several types of parameters for both input (param) and output (result). You can pass and retrieve data of the string, number, date, object and collection types. If the parameter type is not defined, the text type is used by default.

Warning: Using this command to call directly a JavaScript function that displays a dialog (alert(), print()...) is not recommended since the user cannot interact with the Web area while the 4D code is running. If you need to implement such interface, for example you can call setTimeout(function(){alert();}, 50)) to let the execution of the 4D code finish and allow user interaction. 

Calling a JavaScript function with 3 parameters:

 $JavaScriptFunction:="TheFunctionToBeExecuted"
 $Param1:="10"
 $Param2:="true"
 $Param3:="1,000.2" `note "," as thousands separator and "." as the decimal separator
 
 WA EXECUTE JAVASCRIPT FUNCTION(MyWArea;$JavaScriptFunction;$Result;$Param1;$Param2;$Param3)

The "getCustomerInfo" JavaScript function receive a number ID as parameter and returns an object:

 C_OBJECT($Result)
 C_LONGINT($ID)
 $ID:=1000
 WA EXECUTE JAVASCRIPT FUNCTION(*,"WA";"getCustomerInfo";$Result;$ID)



See also 

WA Evaluate JavaScript

 
PROPERTIES 

Product: 4D
Theme: Web Area
Number: 1043

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v11 SQL Release 2
Modified: 4D v14
Modified: 4D v16 R4

 
ARTICLE USAGE

4D Language Reference ( 4D v20 R7)