There are two ways to add a message to a Control:
- by passing in a string:
- by passing in a Text:
A Text can have multiple substitutions in it, e.g. "You cannot order && with &&". Any double ampersands (&&
) present in the Text can be substitued for a value, provided in an array as a separate paramater to the add...MessageText
functions.
// texts.myTextId.text = "You cannot order && with &&"
// The first && will be replaced with the value of the myField Field
// The second && will be replaced with "caviar"
var substitutionArray = [fields.myField.value, "caviar"];
controls.myButton.addInfoMessage(texts.myTextId, substitutionArray);
// output: "You cannot order ketchup with caviar"
You can stop the execution of the rest of the event by setting the stopProcessing
parameter to true e.g. controls.myControl.addErrorMessage("My message", true);
It is often more convinient to add the message to the owner of the event using event.owner.addErrorMessage("My message");