Script (Property)

Applies To:

EventScript object

Description:

The Script property is a read/write string containing the event handler’s JavaScript source code, as it is seen in the Script editing dialog.

You have to alternate single and double quotes to avoid problems with string parsing, for example, write:

 'Console.Writeln("Step 1")'
or
"Console.Writeln('Step 1')"

and not,

"Console.Writeln("Step 1")"
or
'Console.Writeln('Step 1')'

Action:

Read-write, String

Example:

This example shows how to create a command button named “cbcreated” on an OnClick event. The script also writes the results of the script to the Console Window:

Console.Writeln("Start Dynamically Add CommandButton")

Console.Writeln("Step1")
var oCBShape = ActiveDocument.Sections["Dashboard"].Shapes.CreateShape(bqButton)

Console.Writeln("Step2")
oCBShape.Name = "CBCreated"
oCBShape.Text = "CBCreated"
oCBShape.Visible = true
oCBShape.Enabled = true
oCBShape.Locked = false
//Font color not enable for CommandButtons
//oCBShape.Font.Color = bqBlue
oCBShape.Font.Effect = bqFontEffectUnderline
oCBShape.Font.Name = "Ariel"
oCBShape.Font.Size = "12"
oCBShape.Font.Style = bqFontStyleItalic

Console.Writeln("Step3")

Console.Writeln("Width: " + oCBShape.Placement.Width)
Console.Writeln("Height: " + oCBShape.Placement.Height)

oCBShape.Placement.Modify(25, 25, oCBShape.Placement.Width, oCBShape.Placement.Height)

Console.Writeln("Step4")

if (Application.Type != bqAppTypeThinClient)
{
oCBShape.EventScripts["OnClick"].Script = 'Console.Writeln("OnClick")'
oCBShape.EventScripts["OnClientClick"].Script = 'Console.Writeln("OnClientClick")'
}
else
{
oCBShape.EventScripts["OnClick"].Script = 'Console.Writeln("OnClick")'

oCBShape.EventScripts["OnClientClick"].Script = 'alert("OnClientClick")'
}

Console.Writeln("Step5")

oCBShape.OnClick()
oCBShape.OnClientClick()

Console.Writeln("End Add CommandButton")