# SyteLine Form Script Generator for WinStudio Forms

> Source: https://netray.co/tools/syteline-formscript-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Fill in the form, IDO, properties and target variable to get a VB form script method for SyteLine 9/10 that loads related data and shows it on the form.

## Category

developer

## Erp

Infor SyteLine

## Audience

- SyteLine developer
- ERP administrator
- Mongoose developer

## Tool

**Kind:** template

**Output:** code

**Language:** vb

**Fields:**

#### Form name (class name the editor generates)

**Key:** form_name

**Type:** text

**Default:** Items

**Help:** Keep the class name exactly as the Form Script editor creates it for this form.

#### Script method name

**Key:** method

**Type:** text

**Default:** CheckItemOnHand

#### Source property on the primary collection

**Key:** src_prop

**Type:** text

**Default:** Item

#### IDO to load

**Key:** ido

**Type:** text

**Default:** SLItemWhses

#### Property list (comma separated)

**Key:** props

**Type:** text

**Default:** Whse,QtyOnHand

#### Position of the quantity property (0 = first)

**Key:** qty_index

**Type:** number

**Default:** 1

**Help:** Zero-based position of the property to total within the property list above.

#### Filter template ({0} = source value)

**Key:** filter

**Type:** text

**Default:** Item = '{0}'

#### Order by

**Key:** orderby

**Type:** text

**Default:** Whse

#### Target form variable

**Key:** target_var

**Type:** text

**Default:** vOnHand

#### Message text ({0} = source value, {1} = total)

**Key:** message

**Type:** text

**Default:** Item {0}: total on hand across warehouses is {1}

#### Optional: collection property to write instead

**Key:** write_prop

**Type:** text

**Default:** UfOnHandTotal

**Help:** Only used in block 3. Must be a real property on the primary IDO, for example a user-defined field you added.

**Blocks:**

#### 1. Form script method (VB)

**Body:** Option Explicit On
Option Strict On

Imports System
Imports System.Globalization
Imports Microsoft.VisualBasic
Imports Mongoose.IDO.Protocol
Imports Mongoose.Scripting

' Keep the Namespace and class header exactly as the Form Script editor generates them.
Namespace SyteLine.FormScripts
   Public Class {{form_name}}
      Inherits FormScript

      Public Sub {{method}}()
         Dim oCache As IWSIDOCollection = ThisForm.PrimaryIDOCollection
         Dim sItem As String = oCache.GetCurrentObjectProperty("{{src_prop}}")

         If String.IsNullOrEmpty(sItem) Then
            Application.ShowMessage("No current record selected.")
            Return
         End If

         ' Double any single quote so the value cannot break the filter.
         Dim sFilter As String = String.Format("{{filter}}", sItem.Replace("'", "''"))

         ' IDO name, property list, filter, order by, record cap (0 = all rows)
         Dim oResp As LoadCollectionResponseData = Me.IDOClient.LoadCollection("{{ido}}", "{{props}}", sFilter, "{{orderby}}", 0)

         Dim total As Decimal = 0D
         Dim qty As Decimal
         For i As Integer = 0 To oResp.Items.Count - 1
            If Decimal.TryParse(oResp.Items(i).PropertyValues({{qty_index}}).Value, NumberStyles.Any, CultureInfo.InvariantCulture, qty) Then
               total += qty
            End If
         Next

         ThisForm.Variables("{{target_var}}").Value = total.ToString(CultureInfo.InvariantCulture)
         Application.ShowMessage(String.Format("{{message}}", sItem, total))
      End Sub

   End Class
End Namespace

#### 2. Wire the method to an event

**Body:** ' 1. Open the form in Design Mode and open the Form Script editor; paste the Sub into the class.
' 2. Add a form variable named {{target_var}} (Form > Variables) if it does not exist,
'    and bind a display component to it if users should see the value.
' 3. Add a button and give it a custom event, for example CheckOnHand.
' 4. Add an event handler for that event: response type Script, method {{method}}.
'    (The wording of the response type list differs slightly between Mongoose versions.)
' 5. StdFormPredisplay runs before the primary collection has records,
'    so GetCurrentObjectProperty usually returns an empty value there.
'    Use it only for setup work, and run lookups like this one from a button or a later event.
' 6. Save, exit Design Mode, refresh the form and test with a known item.

#### 3. Optional: write to a collection property instead of a variable

**Body:** ' Replace the ThisForm.Variables line in block 1 with this when the value belongs on the record.
' This marks the row modified and refreshes bound components; the user still saves the record.
oCache.SetCurrentObjectPropertyPlusModifyRefresh("{{write_prop}}", total.ToString(CultureInfo.InvariantCulture))

' Secondary collections on the same form are reached by index, for example:
' Dim oSec As IWSIDOCollection = ThisForm.GetSecondaryIDOCollection(2)
' Confirm the collection index on your form in Design Mode before relying on it.

**Notes:** Written against SyteLine 9.x / CSI 10.x Mongoose form scripts (VB). Verify on your version before production: the class header the editor generates (Inherits FormScript and the namespace), the five-argument IDOClient.LoadCollection overload, and that the IDO and property names exist for your user. Test in a non-production configuration and export the form to a vendor-free customization layer, not the vendor layer.

## Content

**Intro:** This generator writes a WinStudio form script method for SyteLine 9.x and CSI 10.x that reads the current record, loads rows from another IDO and puts the result in a form variable. It covers the pattern behind most small form customizations: look something up and show it without leaving the form.

**Sections:**

#### How to use it

**Body:** Set the form name to the class the Form Script editor generates for your form, then name the method and the property you read from the current record. Choose the IDO to load and its property list, and give the zero-based position of the numeric property you want to total. The filter template uses {0} for the current value, so Item = '{0}' becomes Item = 'PN-48213' at run time. The script doubles single quotes in the value before building the filter. Finally name the form variable that receives the total and the message the user sees.

**Bullets:**

- Property names are IDO property names (QtyOnHand), not column names (qty_on_hand).
- Record cap 0 returns all matching rows; keep the filter tight.
- Values come back as strings; the script parses them with the invariant culture.

#### Where this lives in SyteLine

**Body:** Open the form, switch to Design Mode and open the Form Script editor for that form. The script is a class that inherits FormScript; ThisForm gives you the form, ThisForm.PrimaryIDOCollection the main collection (an IWSIDOCollection), ThisForm.Variables the form variables and Application.ShowMessage a message box. Me.IDOClient lets the script call any IDO the user has rights to, which is how this method reaches SLItemWhses from the Items form. Event handlers connect the method to a button, a property change or a form event. The customization is saved at the scope you are editing in, so pick the site or group scope deliberately.

#### Worked example: on-hand total on the Items form

**Body:** With the defaults, a user on the Items form selects PN-48213 and clicks a Check On Hand button. The script reads Item from the current row, loads Whse and QtyOnHand from SLItemWhses filtered to that item and ordered by warehouse, and adds QtyOnHand across the rows. If MAIN holds 120 and WH2 holds 35, vOnHand becomes 155 and the message reads Item PN-48213: total on hand across warehouses is 155. If the item has no warehouse rows the total is 0, which is a useful signal in itself.

#### Version differences and gotchas

**Body:** SyteLine 8 used WinStudio scripts with different editors and conventions, so treat this as 9.x and later code. Option Strict On forces explicit conversions; keep it, it catches type errors at compile time. Writing to a collection property with SetCurrentObjectPropertyPlusModifyRefresh marks the row modified, so the user still has to save; writing to a form variable does not touch data. Running lookups in StdFormPredisplay fails quietly because no record is current yet. Large loads in a form script block the user interface, so filter to the current record and avoid record cap 0 on wide IDOs.

**Bullets:**

- Check the method compiles in the editor before wiring events.
- Keep customizations out of the vendor layer so upgrades do not overwrite them.
- Grant the user group read access to the IDO you load.

**Cta:** If your team wants to ask SyteLine questions like this in plain English on your own servers instead of adding a script per form, we can set that up read-only.

**Faq:**

#### What is a form script in SyteLine 10?

**Answer:** A form script is a VB or C# class attached to a WinStudio form in Mongoose. It inherits FormScript and exposes methods that event handlers call. Through ThisForm, Application and IDOClient it can read and set form values, show messages and load or update data through IDOs, all inside the user's session and permissions.

#### Is a form script the same as personalization?

**Answer:** No. Personalization changes layout, captions, defaults and visibility without code and is the first thing to try. A form script is code for behaviour personalization cannot express, such as looking up another IDO and computing a value. Use the lightest option that works, because scripts need testing after each upgrade.

#### Why does GetCurrentObjectProperty return an empty string?

**Answer:** Usually because no record is current when the method runs, for example in StdFormPredisplay or before a filter-in-place has loaded rows. It also happens when the property name is wrong or belongs to a secondary collection. Run the method from a button or later event and check the exact property name on the primary IDO.

#### Can a form script update data in another IDO?

**Answer:** Yes, IDOClient also exposes UpdateCollection and method invocation, and updates go through the IDO with its validation. Keep updates rare in form scripts, confirm with the user before posting, and prefer an IDO method or extension class when the logic must also run from integrations, not only from one form.

## Search terms

syteline formscript, syteline form script example, syteline 10 personalization, syteline forms, syteline items form, mongoose form script vb, IDOClient.LoadCollection form script, ThisForm.PrimaryIDOCollection

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
