Dynamic Conditional Visibility in SyteLine Form Scripts
Conditional visibility is one of the most requested SyteLine form customizations. Business users want forms that adapt to context: showing manufacturing fields only for make items, hiding approval sections until the order reaches a certain status, or displaying different tabs based on the customer type. SyteLine's scripting model supports dynamic visibility through form component manipulation in event handlers.
Controlling Component Visibility in Event Handlers
Every visual element on a SyteLine form is accessible as a named component through ThisForm.Components collection. To show or hide a component, set its Visible property to true or false in the appropriate event handler. For field-level visibility, target the component by its Name property as defined in the Form Designer. For tab visibility, reference the TabPage component. For grid column visibility, access the grid's column collection. Always place visibility logic in StdObjectLoaded so it re-evaluates each time the user navigates to a different record.
- Hide a field: ThisForm.Components["txtApproverNotes"].Visible = false;
- Show a tab: ThisForm.Components["tabManufacturing"].Visible = (itemType == "M");
- Toggle grid column: ThisForm.Components["gridLines"].Columns["DiscountPct"].Visible = showDiscounts;
- Show/hide a group box: ThisForm.Components["grpShippingDetails"].Visible = (status != "Draft");
- Always use StdObjectLoaded for record-dependent visibility to handle navigation correctly
Multi-Condition Visibility Patterns
Complex forms often require visibility rules that depend on multiple field values, user roles, or external data. Implement a visibility rules engine by defining conditions as a configuration structure rather than hard-coding each rule. Create a function that accepts a list of component names and their visibility conditions, then evaluates all rules in a single pass during StdObjectLoaded. This pattern scales much better than writing individual if-statements for every field and makes it easy to adjust rules without modifying the script logic.
- Rule-based visibility: var rules = new Dictionary<string, Func<bool>> { {"txtApproval", () => status == "Pending"} };
- Apply all rules: foreach (var rule in rules) { ThisForm.Components[rule.Key].Visible = rule.Value(); }
- Role-based visibility: check ThisForm.ActiveUserGroups.Contains("Managers") for role-dependent fields
- Cascading visibility: when parent field is hidden, automatically hide all dependent child fields
- External data visibility: load a configuration IDO to drive visibility rules without code changes
Performance Considerations for Visibility Scripts
Visibility scripts run on every record navigation, so performance matters for forms with many controlled components. Avoid calling IDO methods inside visibility logic for StdObjectLoaded; instead, cache the required data during StdFormLoaded and reference the cache during navigation. Batch component updates: set all Visible properties before the form renders rather than toggling them one at a time. If a form has more than 20 visibility rules, consider restructuring the form into multiple simpler forms or using role-specific form variants.
- Cache lookup data in StdFormLoaded: load user permissions and configuration once per form session
- Batch updates: calculate all visibility values first, then apply them in a single loop
- Avoid IDO calls in StdObjectLoaded visibility logic: pre-load reference data during form initialization
- Measure handler execution time: StdObjectLoaded should complete in under 100ms for responsive navigation
- Consider form variants: create OrderForm_Standard and OrderForm_Advanced rather than 50+ visibility rules
Netray AI agents generate optimized visibility scripts based on your business rules. Define conditions in plain language and get production-ready SyteLine form scripts instantly.
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 Common Script Functions Library
Reusable SyteLine script function library. Copy-paste patterns for property access, IDO calls, validation, formatting, and UI control in CloudSuite Industrial forms.
Infor SyteLineSyteLine Form Variables and Properties Guide
Work with SyteLine form variables, session properties, and component properties. Manage state across events and forms in Infor CloudSuite Industrial development.