> Edit VBScript for

Edit VBScript for

The VBScript for: window is displayed when you select the Edit VBScript function from the VBScript Editor screen.

It comprises the following panes:

  • Procedures

  • VBScripts

  • Variables

  • Field Properties

  • Push Notifications

  • Workflow

  • Notepad

  • Sample code

  • VBScript Modules

Toolbar and menu

Field Description
File
Option Description
Print Select this to print the code for the script.
Print Preview Select this to print the code for the script in a preview screen. You can also select to print the code for the script from the preview screen.
Edit
Option Description
Undo Undo the previous change you made to the script.
Cut Cut the currently highlighted code from its current position.
Copy Copy the currently highlighted code.
Paste Paste the previous cut or copied code to the current cursor location.
Find text Locate text within the code.
Field properties Define the properties for a field. The field attributes, behaviour and values can be defined.
Toggle Bookmark Place a bookmark against the currently selected line (Ctrl+T).
Toggle Breakpoint Highlight a line in the code for navigation purposes (i.e. as a visual aid).
Next Bookmark Jump to the next bookmark (F3).
Previous Bookmark Jump to the previous bookmark (F4).
Format
Option Description
Font Define the font required for the VBScript code.
Options
Option Description
e.net Logon Method This indicates the method you want to use to interact with business objects if you are not using the default Call Business Object function (i.e. using Web Services or COM/DCOM).

This is a global setting that affects all operators and all companies.

VBScript Timeout Select this to define the length of time (in seconds) before the VBScript is interrupted and the operator given the option to terminate the script, or to let it continue.

This can be useful when writing new code and running it the first few times. If there is a fault in the code that causes it to enter a loop, the timeout option allows the operator to exit the script gracefully without having to terminate SYSPRO.

This is a global setting that affects all operators and all companies.
Show Line Numbering This displays a column with line numbers. This can help you locate scripting errors as the processor typically includes the line number that is causing the error.
Show Selection Margin This displays a column with bookmarks.
Enable Virtual Space Select this to insert space characters at the end of each line. This is useful when you are using the keyboard arrow keys to navigate and the lines of code are different lengths.
Actions Select this to programmatically invoke a section of the code of a SYSPRO program from your VBScript. This function is only enabled where a form implements actions and the available actions are specific to the form being edited.

Only one action can be invoked within a function. If there are multiple actions in a function, only the last one will be run.

A complete list of available actions is listed in the IMPVBS.IMP file located in the \Programs folder.

[Note]

Actions have largely been superseded by the ToolbarButton system variable that enables you to develop code to manipulate any button on any toolbar.

Call Business Object Select this to call business objects using SYSPRO architecture (i.e. the enetGUID system variable) instead of needing to configure DCOM or Web Services to interrogate or post data.

e.net Solutions does not need to be licensed in order for you to use the business objects within a form. Using these objects also does not consume an existing e.net Solutions functional area license.

The client date is used for business objects invoked by VBScripts run from the client machine when the Use client system date option is enabled (Operators).

[Note]

Each time a VBScript is executed and the SystemVariables.CodeObject.enetGUID variable is used in a VBScript function, the VBScript automatically performs a logoff after executing that script function.

This effectively means that the generated GUID is invalidated after each script function is executed.

SYSPRO still offers unlimited use of the business objects inside SYSPRO, as SYSPRO's customization within the SYSPRO product is used and not linked or passed to any external application.

If you use the generated GUID for applications outside the bounds of the VBScript, the applications will fail. To prevent this, you need to ensure that your application does not to rely on a GUID that has been written to a file or passed as a parameter to your application inside a script function.

FieldDescription
Query Business ObjectYou use this field to indicate the query type business object to use.

You can use the browse icon to view a list of query business objects available.

Business ObjectYou use this field to indicate the business object to use.
Insert VBScriptSelect this to insert the code for the business object you indicated you wanted to use.
ParametersThis displays the parameters for the selected business object.
Parameters XSDThis displays the XSD schema for the parameters for the selected business object.
Document This displays the document for the selected business object.
Document XSDThis displays the XSD schema for the document for the selected business object.
Sample XMLOUTThis displays the sample XML Out code for the selected business object.
Syntax check Select this to check the syntax of your code. Error messages are displayed for errors found in the syntax.
Markup Editor Select this to load the XAML Markup Editor program. XAML (eXtensible Application Markup Language) is a display markup language that is used to display information in different formats.

There are over 30 XAML markup templates that ship with SYSPRO which can be applied to listview columns and customized panes.

Procedures

This pane indicates a list of the functions available within the script currently being edited, regardless of whether these are standard SYSPRO functions or custom-created. The the first 100 procedures or functions are displayed.

VBScripts

This pane is the main section of the VBScript for: screen that contains the code that you enter either directly in the pane of by inserting code snippets from the Sample Code or VBScript Modules panes.

Variables

A set of unique variables are associated with each customized pane, dependent on the type of object contained in the pane.

Some variables are common to all type of objects.

Variable Description
BarLabelClicked variable (Read-only) This contains the label of the bar that was clicked.
BarPointClicked variable (Read-only) This contains the point of the bar that was clicked.
BarSeriesClicked variable (Read-only) This contains the series of the bar that was clicked.
BeforeChangeValue This is a system variable of type 'string' and contains the value of a form field or a list view cell before a change has been applied.

This variable should only be used in the OnAfterChange events, or OnItemCheck event for a list view.

CancelStandardAction This is a system variable and can be used to prevent SYSPRO from executing it's built-in function after the OnAfterChange VBScript event in a form.

When you have the following line within the OnAfterChange function:

SystemVariables.CodeObject.CancelStandardAction = true 

the application will not execute any standard action built into the application.

This is useful when you want to override the default behaviour of the SYSPRO application.

ColumnClicked variable (Read only) This contains the column number for the OnLinkClicked event.
DesktopAlert variable (Write-only) A desktop alert is a popup window that can be programmed to contain hyperlinked text.
GlobalVariable variable (Read-write) This is a unique variable for the current customized pane only.

For example: You may want to display a desktop alert when a bank balance exceeds 50.000.00, but you only want the desktop alert to be displayed once. You use the global variable to store the highest bank balance value.

GraphData variable (Write only) This variable takes an XML string and populates the graph with the specified data. The data is passed as columns and rows, the same as with a table.
GraphDataIn variable (Read-only) This contains the legend name(s) and the graph values separated by a TAB character. This variable is useful if you allowed the user to edit the graph values and you wish to retrieve these values at some point.
GraphProperties variable (Write only) This variable takes an XML string and creates the columns to be used in the graph. Typically this code would be applied in the OnLoad event, and the data would be applied in the OnRefresh event.
ListviewArrayIn variable (Read only) Double-click this variable in the treeview to insert the following variable into the script editor:
CustomizedPane.CodeObject.Array

This contains an array of all rows and columns in the listview. You should use this variable to interrogate the contents of all cells in all rows in the listview.

If you want to change the contents or attributes of any cell, then you should modify the variable: ListviewArrayOut.

Typically, you would use this variable in the OnPopulate event, since this event fires when the listview has been updated with new data. You would then iterate through the listview array and modify any cells as appropriate using the ListviewArrayOut array.

ListviewArrayOut variable (Write only) Double-click this variable in the treeview to insert the following variable into the script editor:
CustomizedPane_OUT.CodeObject.Array

This contains information about cells in the listview that you wish to modify. The array is two-dimensional and consists of columns and rows. The array uses zero-based indexing.

ListviewClearData When set to true, the current listview is cleared out and a new listview is created with the data specified. When set to false, the data specified is appended to the existing listview.
ListviewData variable (Write only) This variable takes an XML string and populates the listview with XML elements associated with the PrimaryNode as defined in the variable ListviewProperties.

Only child elements one level below the PrimaryNode will be processed and added to the listview.

ListviewDesigner Select this to design a customized listview and generate the VBScript code for the listview.
FieldDescription
Insert VBScriptGenerate the VBScript code for the listview according to the Properties and Column information you indicated. The script is inserted into the VBScript editor pane. At least one listview column must be added before you can use this function.
PropertiesIndicate the properties to apply to the entire listview.
Primary nodeIndicate the primary XML element node to match in the XML data.
StyleIndicate whether you want to create a data grid with iterative rows or a form with caption/value pairs.
Auto insert rowAllows a data grid to automatically insert new rows and also enables the Paste functions.
Auto size columnsAutomatically sets the listview columns widths to fit the window size.
Allow DEL to deleteEnable the use of the Delete key to delete the currently highlighted listview row.
Auto row highlightThe first column in the listview is used as a highlight (an icon is displayed in this column to indicate the currently selected row). This enables the right click context menu so you can select to insert a row above or below the currently highlighted line or add a row to end.
Auto undoEnables the use of CTRL+Z to restore rows previously deleted using the Delete key. This applies during the current run of the program only.
Enable drag/dropEnables dragging and dropping rows within the grid.
Populate visible columns onlyOnly displays data for a column in the listview when the column is visible, which improves listview loading time.
Freeze column countIndicates the number of columns to freeze when scrolling horizontally (when the horizontal scroll bar is displayed).
ColumnUse this pane to define the listview columns and their properties.
Add ColumnSelect this to save each column you define.
ColumnsThis displays the listview columns added using the Add Column option.
ListviewProperties variable (Write-only) This variable takes an XML string and creates the columns to be used in the listview (e.g.
CustomizedPane.CodeObject.ListviewProperties = xml
string.
ListviewRowReturned variable (Read only)

When the operator double-clicks a row in a listview, the contents of each cell in a row are returned in this variable. Each cell is separated by a TAB character (a blank cell will still contain a space character before the TAB character).

The OnDblClick event can be used to trap the event when you double-click a row.

MultimediaPath This is a system variable which returns the multimedia path in a VBScript. The path corresponds to your definition within the IMPACT.INI file.
OnUndo

Restore the records deleted in a ListviewRowReturned variable.

Cancel the Undo using the following statement:

CustomizedPane_OnUndo = false
PostChangeEvent Set this to 1 to force the current form to be set as having been changed and enables the SAVE button.

For example: To force a form to be marked as changed, insert the following code:

SystemVariables.CodeObject.PostChangeEvent = "1" 
RefreshValue variable (Read-write) This contains the value passed by another form or pane to this customized pane.

For Associated panes, whenever the associated field changes, a refresh event is automatically fired in the associated pane and the value of the associated field is passed to the associated pane. The VBScript against the OnRefresh event handles everything else. The RefreshValue only exists for the time it takes for the script to run.

For example: If you add an associated pane to the Job field in the Part Billings program (as this is the primary field for this query) then each time you change the job number in the toolbar, the Job field changes and the associated pane refreshes. However, if the Job field does not change, the refresh event is not fired for the associated pane. Similarly, if you add an associated pane that was associated with the Customer field, when the job number changes, the Customer may or may not change depending on whether the job is for the same customer as the previous job.

For this reason the Refresh button is disabled on the listview toolbar of an Associated pane. If you need to add the Refresh button to the toolbar of an Associated pane you will need to change the code yourself. The code would need to store the RefreshValue in one of the VBScripting Global Variables so that it is available after the refresh event that was fired by the associated field changing.

ScriptFunction The purpose of this variable is to enable the script developer to know which event caused the script to execute and not to indicate the name of the current function procedure being executed.
SQLConnectionMethod This is a system variable derived from the SQLMET= entry in IMPACT.INI file (see System Setup).

This caters for a single character. 1 indicates a Connection string method. Anything else indicates ODBC DSN.

SQLServerName This is a system variable derived from the SQLSSN= entry in the IMPACT.INI file (see System Setup).

Use this to update the SQL Server Name to whatever you desire. This variable caters for up to 50 characters.

SystemVariables (actions)  
ActionToInvoke This variable loads the same screen as the Actions button from the toolbar of the VBScript for: screen. Although the Actions button on the toolbar is only enabled if there are actions available for the pane, the ActionToInvoke variable name is always available. A message is displayed if you attempt to use the variable and there are no actions available for the pane.
SYSPROBrowseToRun This loads the Run SYSPRO Browse Program screen which contains an entry field for the name of the browse, a browse button that displays a list of SYSPRO modules and programs, and an Insert VBScript button. If you know the name of the browse, you can enter it at the prompt, otherwise use the browse functionality to locate the name of the required browse program.

This function is supported within a toolbar script, however, using this variable does not do anything differently to SYSPROProgramToRun, as the selected browse program cannot return any data since it's not specifically associated with any toolbar entry field.

SYSPROProgramToRun This loads the Run SYSPRO Program screen. You can pass a variable to the program that is being called, delimited with a space character.
ToolbarButton This loads the Modify Toolbar Buttons screen which contains options to:
  • enable/disable a button

  • make a button visible/invisible

  • make a button's checkbox checked

  • cause the action against a button to be executed

  • change the value of a button that accepts input

  • or any combination of these options

Field Properties

This pane assists you in programmatically changing the properties of a field by displaying the available properties and inserting the relevant code for you when you select the Insert button.

Field properties consist of one or more XML attributes that exist within an XML string. This XML string is placed against the field for which the properties are to be set.

To set field properties against a field, you first supply the field's variable name, followed by an equals sign, and the field properties' XML.

A field property remains set until it is changed either by the program (in the case of values because new values are retrieved and redisplayed) or your code changes, or you exit the program.

Field Description
Insert VBScript Code Select this to build up the XML according to your field property settings and insert this code at the last cursor position within the VBScript pane.
Reset Fields This resets all the properties back to their default values. Changes made to the Field Properties pane while in the VBScript editor are cumulative. Although this is useful when you are building up field properties in your code for a specific field, if you are going to start setting the field properties for another field we recommend that you first reset fields.
Icons This loads the Change Icon screen that contains all the icons that are available.
Field attributes These options enable you to define the cosmetic attributes of the field.
Background color Defines the background color of the value section of the field. Use the dropdown selector to select a standard color.
Select Color Select this to indicate the color you require from a wider spectrum of colors. This option is only enabled when you indicate the color as Other.
Caption background color Defines the background color of the caption.
Foreground color Defines the color of the text in the value section of the field. You use the dropdown selector to select a standard color.
Select Color Select this to indicate the color you require from a wider spectrum of colors. This option is only enabled when you indicate the color as Other.
Caption foreground color Defines the foreground color of the caption.
Caption is bold Displays the caption in bold.
Add icon Inserts an icon in front of the caption part of the field.
Icon Select the Select icon option to indicate the required icon.
Bold Displays the value portion of the field in bold.
Italics Displays the value portion of the field in italics.
Underline Underlines the value portion of the field.
Indicate required field Define the field as required.
Field height Define the height of a form field.
XAML code Indicate the XAML theme to use for the field. The XAML files supplied with SYSPRO reside in the Base\Samples folder, and they all accept parameters that are used to display values.

These parameters exist within the XAML markup code as numbers with a percentage sign before and after them (e.g. the first parameter is %1%, the second is %2%, etc).

At run time, these parameter numbers are replaced by the supplied values. A large number of these XAML files accept only one parameter, but some accept up to 36. In most cases, if less parameters are supplied than the number of parameters that can be accepted, the parameter numbers are replaced with blank values. However, the graph and trendline XAML markup files require a minimum number of parameters to be able to render correctly. If insufficient parameters are supplied, the XAML will not be able to render properly and may display its source code in the cell. If you use the XAML code field property against a cell without specifying a value, the current content of the cell is automatically supplied to the XAML markup code as the first parameter (%1%).

Field behaviour  
Change case Select this to specify the case of the text entered into the field's value.

You typically select this option to ensure that a field contains consistent information and is always in either upper or lowercase.

Read-only Select this to set the field as read only. This prevents any direct operator action from being performed on the field using the mouse or the keyboard.

The value of the field can, however, be changed using scripting (e.g. if events against other fields or forms cause a script to be invoked and that script contains lines that modify the value against the read-only field, then the lines are executed and the field value is modified accordingly).

Visible This enables you to indicate whether the field is displayed.

You can use this to make a row in a listview non-visible, depending on the value of a specific column in the listview.

Set focus on this field Select this to place the cursor on the value section of the field.

This is useful when you want to validate the field as the cursor focus is returned to the field if the validation fails.

Upper Select this to set the text in the field to uppercase, regardless of how it is entered.
Lower Select this to set the text in the field to lower case, regardless of how it is entered.
Mixed Select this to set the text in the field to normal text entry.
Add a button Select this to add a button to the field. This is used for fields in entry forms.

The button is placed to the right of the value entry area of the field and is only displayed when focus is set on the entry area.

If text is supplied for a button against a field, then the text supersedes any button already defined against the field.

Button wording You use this field to enter the text to display for the button.
Add menu text Select this to add one menu item to a SmartLink against the field value.

If a SmartLink does not exist, it is created for you.

A SmartLink can be added to a field on a display form, an entry form or a listview and is displayed as a SmartLink Information icon.

When you move your mouse pointer over this link, and upside down triangle is displayed to signify that you can select the SmartLink to display a menu. Enabling the Add menu text option allows you enter the text to display on the menu.

Menu text Enter the text you want to display in the SmartLink menu when an operator selects the SmartLink icon with the mouse pointer.
Password mask Select this to display underscore ( _ ) characters in the data entry portion of the field instead of the actual data entered.
Input mask

Enter a mask to limit the type of characters and the number of characters that can be entered for a field value.

The input mask consists of character types which define the edit mask and placeholders for the number of characters which can be entered for each specific character type. The placeholders are defined using the underscore ( _ ) key.

Input masks can be applied to editable and non-editable fields, but cannot be applied to a hyperlinked form field (i.e. you cannot apply an input mask and a hyperlink to the same caption on a display form).

The basic format for an input mask is an underscore followed by the mask character (e.g. _0_0_0 for a 3 digit number). For example: The input mask for a telephone number, restricted to only numeric values with the area code displayed inside of parentheses, would be (_0_0_0) _0_0_0-_0_0_0_0.

Additional characters can be combined with the mask characters to create a restrictive field for text entry. For example: you could define an input mask for Stock code as: Color: _L_L_L Size: _0_0_0. This entry would be displayed in the form as: Stock code Color:___ Size: ___

The following mask characters can be used to define the input mask:

Mask characters Description
0 Allow numeric characters (0-9)
9 Allow numeric characters (0-9) or space (' ')
# Allow numeric characters (0-9) or space (' ') or ('+') or ('-')
L Allow alpha characters in upper or lowercase (a - Z)
? Allow alpha characters in upper or lowercase (a - Z) or space (' ')
A Allow alphanumeric characters (0-9 and a-Z)
a Allow alphanumeric characters (0-9 and a-Z) or space (' ')
& All print character only. Allows characters a-z, A-Z and any arbitrary unicode characters. Control characters are not allowed.
H Allow hexadecimal digits (0-9 and A-F)
X Allow hexadecimal digits (0-9 and A-F) and space (' ')
> Automatically changes any alpha character entered to uppercase (A-Z)
< Automatically changes any alpha character entered to lowercase (a-z)
Field values  
Set field value Select this to set a specific value as the default for the field.
New value Enter the specific value you want to set against the field.
Set field tooltip Select this to enter a tooltip against the field (e.g. to display additional information about the field. The tooltip is displayed when you move the mouse pointer over the data portion of the field.

Once set, the property remains for the run of the program, or until it is changed programmatically. To revert to the default setting, you need to set the attribute to ' '.

Tooltip Enter the text to display for the tooltip.
Drop down list The is used to apply a dropdown list to a field. Only items from the list can be selected (i.e. the operator cannot supply a value that is not in the list). The available options are added to the Drop down list field property separated by semi-colons.
Allow drop down entry This is used to indicate whether a dropdown list defined against a field is editable.

For example:

The syntax for a form Order Header with a field DropDownField that has a list that you want to set as editable would be:

OrderHeader.CodeObject.DropDownField = "<Field AllowEntry='true' List='1;2;3;4;5' > </Field>"

Enabling the Allow drop down entry option injects the "AllowEntry='true' " statement. AllowEntry can also be 'false', indicating that the list cannot be editable and you have to select from the drop down list.

Push Notification

You can add VBScript to send out push notifications to Espresso on any mobile device or desktop.

Field Description
Generate VBScript Code Select this to insert the XML code into the current position of the VBScript.
Recipient options  
Send to Indicate to whom you want to send a notification. This default to everyone, but can be to a specific role, specific operator, or the current operator.
Message to send  
Push message text Enter a message of up to 288 characters that you want to send to your Espresso users.
Target application This is the application within Espresso to which the message will be sent.
Send to application Select the specific Espresso application that you want to link to the push message text.
Application variables You can select a specific variable within which the message will be received, for example Customer 0000001 will display in the target application Customers when the notification is opened in Espresso.

If you do not add any variables, the application selected above will be used to receive the notification.

Key field to use This is the key field to which Espresso will link the message to within the selected application. This defaults to the key field for the target application selected above.

For example, you can attach a specific key such as customer or stock code to the message so that when selected, the system will pass the application a specific key to action (e.g. notify a user to change the credit limit value against a customer in the Customers)

Value to use This is the value that Espresso will use to link within the application.

Workflow

This pane enables you to generate the VBScript that the SYSPRO client uses to communicate with deployed workflow processes.

Notepad

This pane enables you to capture information about the VBScript that you do not necessarily want to include as comments within the script itself.

Sample Code

This pane contains sample VBScript code snippets that you can import into your script, and modify as required.

Each snippet displays a short description (that appears within braces) and the first three lines of the code. The snippets will be inserted at the point where the cursor was last positioned.

Field Description
Insert Code Select this to insert the code currently highlighted in the Sample Code pane to your code in the VBScript pane. The code is entered at the point your cursor is currently positioned within the code in the VBScript pane.

VBScript Modules

This pane displays any VBScripts that you have written. In effect, it enables you to create a library of frequently used functions and to reference these in your VBScript. These modules are stored in the \work\vbscripts\vbsmodules folder.

Field Description
Insert Code This inserts the code of the currently highlighted script into your code in the VBScript pane.
New Select this to add a new script.
Edit This enables you to edit the currently highlighted script.
Delete This deletes the currently highlighted script.