setQueryMessage( )

Set a query message dynamically within a rule. This query message is used for query creation when the rule returns false.

The message you set for the query can be a dynamically generated string. You can do this by using variables or functions that return strings. Refer to the examples section below.

The default query message provided on rule creation is used when no dynamic query message is set upon running the rule. If you use the setQueryMessage() function within your logic, the dynamic query message is not set if its value is null, undefined, an empty string, or contains a space only.

Note:

This function cannot be used for rules that send email notifications.

Syntax

setQueryMessage(strMessage)

Parameters

Parameter Required/Optional Description
strMessage Required A string containing the query message. This string can be dynamically generated within the rule expression.

Tip:

You can use the getDateDMYFormat( ) helper function to format a date before passing it to this function.

Return value

A string containing the query message that has been set for query creation. Or, an empty string if any errors occurred during the running of the function.

Examples

Example 3-101 Set the query message when weight is less than 120

// Given "weight" item containing value of 110.
if (weight < 120){
var strMessage = "Subject weight of " + weight + " lb is less than the required weight of 120 lb."
setQueryMessage(strMessage);
  return false; // create query
} else {
 
   return true;  // close query
}
  
// A query is created with message "Subject weight of 110 lb is less than the required weight of 120 lb."