Problem
OmniScript’s standard elements cover a lot, but some inputs need behaviour or validation the stock element does not give: an input that must check a value against rules before the user can move on, a Type Ahead with specific matching, an Edit Block with row-level checks.
What I built
LWC overrides for OmniScript elements: custom input controls, plus Type Ahead and Edit Blocks with specialised client-side validation, styled to behave on several device sizes.
How it works
The pattern: override, do not fork. An OmniScript element can be replaced by a custom LWC that extends the OmniScript base class. It keeps the platform’s data JSON, step handling and navigation, and only changes the rendering and validation of that one element.
Validate on the client, early. Rules run in the component as the user types or leaves the field, and failures are reported through the field’s validity so the Next button and the step’s own validation respect them. Server calls are reserved for what the browser cannot know.
Write back through the platform. Values go back to the data JSON through the OmniScript base API so the rest of the script (conditional views, set values, formulas) sees the same data the user sees.
Responsive by default. Styling is kept small and tuned across phone, tablet and desktop widths.
import { LightningElement, api } from 'lwc';
import { OmniscriptBaseMixin } from 'omnistudio/omniscriptBaseMixin';
export default class ValidatedInput extends OmniscriptBaseMixin(LightningElement) {
@api label;
@api pattern; // regex source supplied from the script's design time properties
@api message = 'Check this value.';
value = '';
handleChange(event) {
this.value = event.target.value;
const input = event.target;
const ok = new RegExp(this.pattern).test(this.value);
// Setting custom validity is what keeps the step's Next button honest.
input.setCustomValidity(ok ? '' : this.message);
input.reportValidity();
if (ok) {
this.omniUpdateDataJson(this.value);
}
}
}