Runs the specified Newlook script then continues execution of the current script.
Newlook Smartclient
Newlook Server
Introduced in Version 10.7 (Newlook Server API).
Introduced in Version 11.0 (Scripting support).
App.RunScript(ScriptName[, FunctionName], [Arguments])
The RunScript method syntax has these parameters:
Part |
Description |
ScriptName |
String specifying the script to run. The script's name should be specified in quotation marks. |
FunctionName |
Optional. String specifying the function to execute. The function's name should be specified in quotation marks. |
Arguments |
Optional. Array of arguments to be passed to the script. The array can contain values of the type string, integer, double or boolean. Arguments can be specified as a JScript array ("TestScript", "TestFunction", [arg1, arg2, arg3, ...]), or as a comma-separated list of arguments ("TestScript", "TestFunction", 1, 2, 3). |
Use this method if you wish to call a script using the Newlook API or from a different script.
This method is the Web API equivalent of 'WebServices' for SOAP.
The RunScript method is typically used if you want to send data to another Newlook script as function parameters and get data back as function return values.
This method should not be used to call a function that exists within the calling script. If you are wanting to call a function within the current script reference it explicitly.
This method returns, on success, the return value of the called function. For instance, if the function returns an integer, then RunScript will return an integer.
The following example uses the Newlook Server swagger API to pass values to the ImperialToMetric script and populate a textbox on the current form with the results:
The following example uses the RunScript method to pass individual address fields to the CreateAddressString function, which creates a single address string, and updates a field on the form with the result:
// Get individual address fields from form
var add1 = App.ActiveForm.StreetAddress.Text;
var add2 = App.ActiveForm.City.Text;
var add3 = App.ActiveForm.Zipcode.Text;
// Pass address fields to CreateAddressString function.
var addressString = App.RunScript("CustomerModules", "CreateAddressString", [add1, add2, add3]);
// update inputs on the active form
App.ActiveForm.FullAddress.Text = addressString;
CustomerModules Script:
// Concatenate address fields into a single address string.
function CreateAddressString(a1, a2, a3)
{
return a1 + " " + a2 " " + a3 + "."
}
The following example uses the RunScript method to pass individual numeric values to the ApplyDiscount function, which returns the discounted total, and updates a field on the form with the result:
// Get invoice and discount fields from form
var inv = App.ActiveForm.InvoiceTotal.Text;
var disc = App.ActiveForm.Discount.Text;
// Pass invoice and discount fields to ApplyDiscount function.
var DiscInvoice = App.RunScript("CustomerModules", "ApplyDiscount", inv, disc);
// update inputs on the active form
App.ActiveForm.DiscountedInvoice.Caption = DiscInvoice;
CustomerModules Script:
// Calculate discounted invoice total.
function ApplyDiscount(inv, disc)
{
return inv - disc
}
RunMacro method | GoToMacro Action