Infor SyteLine

Grid Cell Validation Scripts for SyteLine Forms

SyteLine grids are the primary interface for entering line-level data in orders, jobs, BOMs, and transactions. Unlike header fields that can be validated in StdFormPreSave, grid data requires cell-level and row-level validation that fires as users edit each cell. Implementing grid validation correctly prevents bad data at the point of entry and provides immediate feedback rather than waiting until the user attempts to save the entire form.

Grid Event Model and Cell Change Detection

SyteLine grids expose several events for data validation. The ColumnChanged event fires when a user modifies a cell value and tabs or clicks out of the cell. The RowChanged event fires when the user moves to a different row. The BeforeRowInsert event fires before a new row is added to the grid. Each event provides context about the affected row, column, and value, letting your validation logic target specific cells or apply row-wide rules. Bind your validation handlers to these events in the form script's initialization section.

  • ColumnChanged: fires on cell exit after value change; provides ColumnName and NewValue for targeted validation
  • RowChanged: fires on row transition; use for cross-cell validation that depends on multiple column values
  • BeforeRowInsert: fires before new row creation; use to set default values for new grid rows
  • Access cell value: grid.GetCellValue(rowIndex, "ColumnName") returns the current cell content
  • Cancel edit: set e.Cancel = true in ColumnChanged to reject the value and keep focus on the cell

Common Grid Validation Patterns

The most frequently needed grid validations include range checking on quantity and price fields, referential integrity checks on item numbers and account codes, cross-cell consistency validation (e.g., ship date must be after order date), and duplicate row prevention. For referential checks, use a quick InvokeIDO call to verify the entered value exists in the master data before accepting it. For range checks, compare against configurable min/max values loaded during form initialization. For duplicate detection, scan existing grid rows for matching key values.

  • Quantity range: if (qty <= 0 || qty > 999999) { ShowError("Quantity must be between 1 and 999,999"); e.Cancel = true; }
  • Item validation: InvokeIDO("SLItems", "ItemExistsSp", itemNum, ref exists); if (!exists) reject the entry
  • Date consistency: if (shipDate < orderDate) { ShowError("Ship date cannot precede order date"); }
  • Duplicate row check: scan all grid rows for matching Item + Warehouse combination before accepting new row
  • Calculated field: auto-compute ExtendedPrice = Qty * UnitPrice in ColumnChanged when either value changes

Performance and User Experience Considerations

Grid validation scripts execute frequently, especially during rapid data entry in high-volume order entry scenarios. Keep cell-level validation lightweight: avoid database calls for every keystroke. Instead, cache reference data (valid items, valid accounts) during form load and validate against the cache. For expensive validations like credit limit checks or inventory availability, defer to row-level or pre-save validation rather than cell-level. Provide clear, specific error messages that tell the user exactly what is wrong and what value is expected.

  • Cache valid item numbers in a HashSet during StdFormLoaded for sub-millisecond lookup validation
  • Defer expensive checks: validate inventory availability on RowChanged, not on every cell edit
  • Provide specific errors: "Item ABC123 not found in warehouse MAIN" instead of generic "Invalid value"
  • Visual feedback: highlight invalid cells with a red background color using SetCellBackColor helper
  • Throttle validation: if users paste data into multiple cells, batch-validate after paste completes

Netray AI agents can analyze your SyteLine grid structures and generate comprehensive cell validation scripts with cached lookups and optimized performance. Improve data quality at the source.