Infor SyteLine4 min readNetray Engineering Team

How to Build Form Scripts in SyteLine

Form scripts in SyteLine enable developers to add client-side logic to forms without modifying server-side IDO code. Written in a JavaScript-like scripting language, form scripts handle UI events such as button clicks, field value changes, and form load operations. This guide covers the scripting syntax, event model, and best practices for building maintainable form scripts that enhance the SyteLine user experience.

Understanding the SyteLine Form Scripting Environment

SyteLine form scripts execute within the Rich Client's embedded scripting engine, which supports a subset of JavaScript syntax with SyteLine-specific API extensions. Scripts are attached to forms through the Form Designer's Script Editor, accessible via the Script tab in the form properties panel. The scripting environment provides access to form controls through the thisForm object, which exposes methods for reading and writing property values, showing messages, and invoking IDO methods. Scripts can respond to form-level events like OnLoad, OnSave, and OnDelete, as well as control-level events like OnClick, OnValueChanged, and OnLostFocus.

  • Access the Script Editor through Form Designer > Script tab to view and edit scripts attached to the current form definition
  • Use the thisForm object to access form controls, read property values with thisForm.PrimaryIDOCollection.GetCurrentObjectProperty('PropertyName')
  • Handle form-level events including OnFormLoad, OnFormSave, OnFormDelete, and OnFormClose for lifecycle management
  • Handle control-level events such as OnClick for buttons, OnValueChanged for fields, and OnLostFocus for validation triggers

Writing Common Form Script Patterns

Most form scripts follow common patterns for field validation, conditional visibility, calculated fields, and IDO method invocation. For field validation, use the OnValueChanged event to check the new value against business rules and display a warning or error message using thisForm.ShowMessageBox. For conditional visibility, toggle control visibility based on field values by calling thisForm.FindControl('ControlName').Visible = true or false. Calculated fields can be updated in real time by reading source property values and writing the result to a target property using SetCurrentObjectPropertyValue. When calling server-side IDO methods, use the InvokeIDOMethod function with the method name and parameters.

  • Validate field values in OnValueChanged handlers using conditional logic and thisForm.ShowMessageBox for user feedback with OK/Cancel options
  • Toggle control visibility dynamically with thisForm.FindControl('ControlName').Visible = condition to show or hide fields based on context
  • Calculate derived values by reading source properties and writing results using thisForm.PrimaryIDOCollection.SetCurrentObjectPropertyValue
  • Invoke server-side IDO methods with thisForm.PrimaryIDOCollection.InvokeIDOMethod('MethodName', parameterArray) for complex operations

Debugging and Maintaining Form Scripts

Debugging form scripts requires a systematic approach since the SyteLine Rich Client does not provide a full interactive debugger for scripts. Use the ScriptTrace.Write method to output diagnostic messages to the SyteLine trace log, which can be viewed in the client's diagnostic console. Common issues include incorrect property names causing silent failures, timing problems where scripts execute before data is loaded, and scope issues with variable declarations. Maintain form scripts by documenting each script block with comments explaining the business purpose, keeping scripts under 200 lines per event handler, and storing script backups alongside form exports in version control.

  • Use ScriptTrace.Write('message') to output debugging information to the SyteLine diagnostic trace log for runtime troubleshooting
  • Handle timing issues by checking thisForm.PrimaryIDOCollection.GetCurrentObjectProperty('PropertyName') for null before processing
  • Keep individual event handler scripts under 200 lines and extract reusable logic into helper functions defined at the form script level
  • Export form scripts alongside form definitions to version control, maintaining a change log with dates, authors, and business justifications

Frequently Asked Questions

What scripting language do SyteLine form scripts use?

SyteLine form scripts use a JavaScript-like scripting language proprietary to the Mongoose framework. It supports standard constructs like if/else, for loops, functions, and variables but does not include the full ECMAScript specification. The scripting engine provides SyteLine-specific objects like thisForm, ScriptTrace, and IDOCollection for interacting with the ERP interface. Scripts execute client-side within the Rich Client process, with typical execution times under 100 milliseconds per event handler.

Can form scripts call server-side IDO methods?

Yes, form scripts can invoke server-side IDO methods using the InvokeIDOMethod function on the IDO collection object. This creates an asynchronous call to the SyteLine application server, executing the IDO extension class method and returning the result to the script. Each server call adds 50-200 milliseconds of latency depending on network conditions. Batch multiple related server calls into a single IDO method when possible to minimize round trips and improve form responsiveness.

How do I prevent form scripts from slowing down the UI?

Keep form scripts lean by limiting OnValueChanged handlers to essential validations and calculations. Avoid making server-side IDO calls in high-frequency events like OnLostFocus for every field. Use conditional checks to skip processing when values have not actually changed. Cache frequently accessed lookup values in script-level variables rather than re-querying on each event. Target a maximum of 50 milliseconds per event handler execution to maintain a responsive user interface.

Key Takeaways

  • 1Understanding the SyteLine Form Scripting Environment: SyteLine form scripts execute within the Rich Client's embedded scripting engine, which supports a subset of JavaScript syntax with SyteLine-specific API extensions. Scripts are attached to forms through the Form Designer's Script Editor, accessible via the Script tab in the form properties panel.
  • 2Writing Common Form Script Patterns: Most form scripts follow common patterns for field validation, conditional visibility, calculated fields, and IDO method invocation. For field validation, use the OnValueChanged event to check the new value against business rules and display a warning or error message using thisForm.ShowMessageBox.
  • 3Debugging and Maintaining Form Scripts: Debugging form scripts requires a systematic approach since the SyteLine Rich Client does not provide a full interactive debugger for scripts. Use the ScriptTrace.Write method to output diagnostic messages to the SyteLine trace log, which can be viewed in the client's diagnostic console.

Need help building or optimizing SyteLine form scripts? Netray's SyteLine developers can create maintainable, high-performance form scripts for your specific business needs.