showMessage()
Last updated 12/09/2024
Example
The following code shows a message in the UI if the value entered in the Discount Code field can't be validated.
Show message if invalid discount code
function ValidDiscountCode(five: Five, context: any, result: FiveError) : FiveError {
const discountCodes = new Array<string>('10456A', 'W2341', 'HA888', 'PP8989', 'M567');
for (let i = 0; i < discountCodes.length ; i++) {
if (five.field.DiscountCode === discountCodes[i]) {
return five.success();
}
}
five.showMessage('Unknown discount code');
return five.success(result);
}
Show message if invalid discount code
function ValidDiscountCode(five, context, result) {
const discountCodes = new Array('10456A', 'W2341', 'HA888', 'PP8989', 'M567');
for (let i = 0; i < discountCodes.length ; i++) {
if (five.field.DiscountCode === discountCodes[i]) {
return five.success();
}
}
five.showMessage('Unknown discount code');
return five.success(result);
}