Sales Configuration > Maintaining Sales Configuration Rules
  
Maintaining Sales Configuration Rules
Maintaining General Rules
Use General Rule Maintenance to create, view, edit, or delete general sales configuration rules.

General Rule Maintenance
When creating a rule, you can either build it from scratch, or copy from an existing one and modify it. To copy from an existing rule, click the Copy From Rule button next to the Rule ID field and select the rule you want to copy from in the pop-up browse window. You can then proceed to modify the duplicated rule.
Composing Rules
To compose conditional and assignment rules:
1 In the Rule Editor pane, select a conditional rule type. If you select Conditional, If, Then, and Else statements display; If you select Assignment, only an Assign statement displays.
2 Edit rule statements. For the IF conditional statements, you can convert them to free format and edit the conditions manually. A conditional rule has at least an If Statement and an Else statement.
3 To add a statement after an existing one, click the + sign next to the statement; to delete an existing statement, click the X sign next to it.
4 To change the order of the statements, click the Move Up or Move Down signs next to the statement to move it up or down.
5 Click the Update button to display the rule you are composing in the Preview pane.
Note: Once you click the Update button, you cannot modify existing statements in the current rule. However, you can still delete existing statements and add new ones.
6 Click the Check Syntax button to check whether the rule syntax is correct. If the rule is valid, you can see the status Passed under the button. Otherwise, a Rule Check Configuration window pops up displaying detailed error messages.
Note: The syntax check function only checks the rule in the Preview pane. Any changes you make in the Rule Editor pane are not validated.
7 Click Save to save the rule.
Composing Statements in Basic Format
To compose a conditional statement:
1 Select a variable from the Variable drop-down list. Only variables pertaining to the current master group are available for selection.
2 Select a variable attribute from the Attribute drop-down list. Variable attributes differ for different types of variables in different statements.
 
Statement
Variable Data Type
Available Attributes
IF
numeric, numeric list
Value, Min, Max, Default, Multiplier
IF
text, date, logical, element
Value, Default
THEN, ELSE, ASSIGN
numeric, numeric list
Value, Min, Max, Default, Multiplier, Show
THEN, ELSE, ASSIGN
text, date, logical, element
Value, Default, Pricing Qty, Show
3 Select an operator from the Operator drop-down list. Available operators differ for numeric and non-numeric variables in different statements.
 
Statement
Variable Data Type
Available Operators
IF
numeric, numeric list
=, <>, <, >, <=, >=
IF
text, date, logical, element
=, <>
THEN, ELSE, ASSIGN
numeric, numeric list
=, <>
THEN, ELSE, ASSIGN
text, date, logical, element
=, <>
 
4 Click the icon next to the Values/Options field. A Values/Options window displays.

Values/Options Window (Basic Rule Format)
5 If you are composing a simple conditional statement that does not involve additional expressions or calculations (for example, color = red), use the Basic rule format.
Enter a value or select an option or multiple options in the Values/Options window, which differs for different variable types in basic mode.
When variable data type is numeric, specify a valid numeric value.
When variable data type is text, numeric list, date list, or logical, select an option or multiple options in the list box. Multiple options represent the OR relationship among selected values.
For text, numeric list and date list type variables, when Allow Fill-in is selected, you can enter a value and use the Add button to add new options to the option list. Then you select the options you want.
For element, current date, and specified date type variables, you can only specify value using the Advanced rule format.
6 If you are composing a more complex conditional statement that involves expressions or calculations (for example, If Length > Width * 2), select the Advanced rule format.

Values/Options Window (Advanced Rule Format)
Enter an expression in the advanced format value input box either manually or with the help of the drop-down lists above the input box. You can include any valid combination of available variables, variable options, operators, and functions in the expression. Here is an example of a valid advanced-format expression:
round((Width * Length)/12)
7 Click OK to close the window and return your specified values to the Value field in the conditional statement. You have completed composing the conditional statement.
Composing IF Statements in Free Format
If you are composing complex conditional statements that involve expressions or calculations, you can use the free format. To convert all IF statements to free format and manually edit the conditions, select the Free Format check box next to the first IF statement. Then the system converts all conditions that you have composed to free format. You can also go back from free format to basic format, but all changes in the IF statement are no longer there.

Free Format
Free-format expressions take the form of a Boolean expression, either true or false. You can use all the basic Boolean operators, brackets, ANDs, and ORs, as well as variable names and option names. Option names for text variables are in double quotes, but this does not apply to date list variable options or numeric list variable options.
The free-format mode is applicable only to the IF statement of the rule. A rule can contain only one free-format block, which defines the whole of the IF statement. You cannot combine a free-format IF line with further AND lines for the IF statement in basic or advanced format.
The process of composing a free-format expression consists of entering the details of the expression into the expression editor window. The expression can contain any combination of values, variable options, and Boolean operators with correct Progress syntax. The word IF is there automatically (as for basic and advanced expressions).
Allowing Users to Overwrite Sales Configuration Rules
You can control whether rule assignment can be overwritten by question respondents. If Allow User Override is selected, the system allows the rule assignment to be overwritten when users answer questions in the Questionnaire.

Allow User Override
Example: A sales configuration rule is defined as follows and the field Allow Users Override is selected:
IF: backup-type = Alkaline
THEN: CPU = High
When answering questions in the Questionnaire, the user selects Alkaline for the backup-type option; according to the rule, the CPU option is automatically selected as High. But since now the rule assignment allows user override, the user can still select other CPU options, such as Standard.
By default, Allow Users Override is not selected.
Composing Pricing Rules
You can compose pricing rules using the Pricing Qty attribute of text, date, logical, and element type variables in THEN, ELSE, and ASSIGN statements. Pricing rules are used to set the quantity to be used by the QAD pricing engine for non-numeric features.
Example:  
IF:
salesprice <> 0.00
THEN:
pump:pricing_qty = pricing
ELSE:
pump:pricing_qty = 0
The variable pricing is a numeric feature, which gives the quantity of variant items to be configured. This quantity is important because prices for components can differ depending on the number sold. When users answer one of the first questions on the questionnaire, the pricing variable gets its value. The pricing variable is one subset of independent questions.
The previous rule states that if the user is selecting a feature option for the feature pump, the pricing engine calculates prices based on the value of pricing entered in the questionnaire. Pricing rules differ from ordinary rules in that the right side of the equation contains a feature instead of an option. In this example, the system uses the value of the feature pricing as the pricing quantity for the pump.
Using the value of feature pricing in the right side of the THEN part of the rule is only possible in advanced mode.
Defining Warning Messages
When constructing sales configuration rules, you can define warning messages to display when a particular rule condition is met during the questionnaire entry process.
To define a warning message:
1 Define a logical type variable.
2 Create a sales configuration rule and assign the following function to the variable:
showMessageBox(title, message)
 
Where title is the title of the warning message box and message is the warning message you want to display.
You can enter the message box title and the message in any of the QAD-supported languages.
Example: You define a message and the message box title in Chinese.

Define Message in Chinese
Then when the Chinese questionnaire respondent uses the questionnaire, the system displays the message box title and the message in Chinese.

Message Shown in Chinese
3 Attach the rule to an item. When the system processes the rule in the questionnaire, there is a warning message.
Using Custom Functions in Sales Configuration Rules
The system lets you easily define and maintain custom functions in the pcfunc.i file and use them in sales configuration rule definitions. Custom functions are called and executed when the system processes general rules and item rules containing them.
Note: Custom functions cannot be called from rule tables.
To use a custom function:
1 Edit the pcfunc.i file to define your custom function using Progress. Here is a sample function that converts time from minutes to seconds:
function CovertTime returns integer (input Hours as integer):
return Hours*60
end function.
2 Define a rule in General/Item Rule Maintenance in the advanced mode and assign the custom function to a variable/feature; for example:
If TimeUnit = “Minutes” Then Duration = ConvertTime (Hours)
Where TimeUnit, Duration, and Hours are all defined variables or features.
3 Use Check Syntax to validate both the rule and the custom function.
4 When you launch the questionnaire for the configurable item, if you set TimeUnit to Minutes and Hours to 2, Duration is 120.
5 Whenever there are any changes to the custom function in pcfunc.i, analyze the configurable item using Configuration Analyzer to make the changes effective.