Best Practices
Forsta HX Platform - API Scripting Guide
Best Practices
⭐ Forsta Standard Coding Practices
- Use Forsta methods for all data operations:
f('Qid').domainValues()to get all optionsf('Qid').item(code).toBoolean()to check selectionsf('Qid').item(code).toNumber()to get numeric valuesf('Qid').set(value)to set valuesf('Qid').get()to get values
- Use jQuery only for DOM manipulation:
.show(),.hide(),.addClass(),.find() - Loop through domainValues(): Always use
forloop orforEachwith.domainValues() - Clear hidden values: When hiding questions with jQuery, clear their data separately if needed
- Use descriptive variable names:
totalSpendnotts - Comment your logic: Especially calculations and business rules
- Test all paths: Verify all conditional logic works correctly
Performance
- Cache selectors in variables
- Use event delegation
- Minimize DOM manipulations
- Debounce input events
Accessibility
- Clear error messages
- Use ARIA labels
- Keyboard navigation
- Screen reader friendly