Reusable Script Function Library for SyteLine Development
Every SyteLine development team ends up writing the same utility functions repeatedly: getting and setting property values, formatting dates, validating required fields, calling IDO methods, and controlling form UI elements. Building a shared function library eliminates this duplication, ensures consistent patterns across all form scripts, and accelerates development for new team members.
Property Access and Data Helper Functions
The most commonly needed functions wrap SyteLine's property access methods with null safety, type conversion, and default value handling. The raw GetCurrentObjectProperty method returns an object that must be cast and null-checked. A wrapper function like GetStringProperty(propertyName, defaultValue) handles the casting, null coalescing, and trimming in one place. Similarly, typed wrappers for decimal, integer, date, and boolean properties eliminate repetitive type conversion code scattered across every event handler.
- GetStringProp(name): return (ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty(name) ?? "").ToString().Trim()
- GetDecimalProp(name): decimal.TryParse(GetStringProp(name), out var val) ? val : 0m
- GetDateProp(name): DateTime.TryParse(GetStringProp(name), out var dt) ? dt : (DateTime?)null
- SetProp(name, value): ThisForm.PrimaryIDOCollection.SetCurrentObjectProperty(name, value?.ToString())
- GetBoolProp(name): return GetStringProp(name).Equals("1") || GetStringProp(name).Equals("True", StringComparison.OrdinalIgnoreCase)
IDO Call Wrapper Functions
Wrapping IDO calls in helper functions standardizes error handling, parameter formatting, and return value extraction. A LoadIDOData function accepts the IDO name, property list, filter, and record cap, returning a DataTable or list of dictionaries. An InvokeIDOMethod function wraps the InvokeIDO call with try-catch, logging, and meaningful error messages. These wrappers save significant time when building forms that interact with multiple IDOs and need consistent error handling behavior.
- LoadIDOData(idoName, props, filter, cap): wraps LoadCollection with error handling, returns DataTable
- InvokeSafe(idoName, method, params): wraps InvokeIDO in try-catch, logs errors, returns success/fail tuple
- GetLookupValue(idoName, returnProp, filterProp, filterValue): single-value lookup helper for dropdowns
- CountRecords(idoName, filter): returns integer count of matching records for existence checks
- BatchUpdate(idoName, commands): wraps UpdateCollection with transaction handling and retry logic
UI Control and Validation Utilities
Form UI manipulation follows repetitive patterns: showing/hiding fields, enabling/disabling controls, setting colors for visual indicators, and validating required fields. A shared library of UI utility functions reduces each operation to a single descriptive call. RequireFields validates a list of property names and highlights missing ones. SetFieldVisibility toggles one or more named components. SetFieldReadOnly locks fields based on record status. These utilities keep event handler code focused on business logic rather than boilerplate UI manipulation.
- RequireFields(["CustNum", "OrderDate", "Whse"]): validates non-empty, returns list of missing fields with highlighting
- SetFieldVisible(componentName, isVisible): wraps ThisForm.Components[name].Visible = isVisible with null check
- SetFieldReadOnly(componentName, isReadOnly): sets the control's ReadOnly property with existence validation
- SetFieldBackColor(componentName, color): visual indicator for mandatory or warning fields
- ShowTab(tabName, isVisible): controls tab page visibility for wizard-style form workflows
Netray AI agents maintain a curated library of SyteLine script functions tailored to your environment. Generate optimized utility code and keep your development team consistent.
Related Resources
SyteLine Form Event Handlers Guide
Master SyteLine form event handlers including StdObjectLoaded, StdObjectSaved, and StdObjectDeleted. Build responsive forms in Infor CloudSuite Industrial.
Infor SyteLineSyteLine Conditional Visibility Scripts
Show and hide SyteLine form fields dynamically based on data values. Conditional visibility scripts for tabs, grids, and controls in Infor CloudSuite Industrial.
Infor SyteLineSyteLine Global Scripts vs Form Scripts
Understand when to use SyteLine global scripts versus form-level scripts. Compare scope, performance, and maintenance trade-offs in CloudSuite Industrial development.