Overview of validating variants and variation points
You can create validation script for Variants and Variation Points.
A validation script can assess the following information in the model:
• The Status of any Variant or Variation Point in the context of the Decision Set that is being edited in the Decision Set Editor or Variant Selector.
• The Value of any Variant parameter in the context of the Decision Set that is being edited in the Decision Set Editor or Variant Selector.
• Any model item property through the Modeler automation interface.
The validation script can then set the Status of the owning Variant or Variation Point to inconsistent in the Decision Set Editor or Variant Selector and specify the text that is displayed as the Reason for the inconsistency.
For more information about VBScript, see the VBScript user's guide and reference guide on the Microsoft MSDN website. At the time of writing this topic, the button that follows opens the VBScript section of the
Microsoft MSDN website
You can show the validation script of a Variant or Variation Point on a diagram: right-click the Variant or Variation Point, point to Add, and then click Validation Script.
The following example demonstrates how validation script can set the Status of a Variant to Inconsistent.
Our model has three Variants named Variant1, Variant2 and Variant3.
We want Variant1 to be shown as inconsistent if the Status of Variant2 and Variant3 are both set to Included.
We open the Property Pages of Variant1 and click the Validation Script tab.
We select the Has Script check box and see that a framework script has been added to the script.
We delete the <constraint is met> place holder and add the text that follows to validate whether the Status of both Variant2 and Variant3 are set to Included. We change the Script.Result text to 'Variant2 and Variant3 are both included'. Note that Variant2 and Variant3 are model object references that we created by dragging Variant2 and Variant3 to the script.
We create a Decision Set and open the Decision Set Editor. The Status of Variant1 is not Included, so its value is not validated.
We set the Decision of Variant1 to Include. The Status of Variant1 is now set to Included so its Validation Script is run. Variant2 and Variant3 are not both included, so Variant1 is not set to inconsistent.
We set the Decision of Variant2 to Include. The Status of Variant1 remains as Included.
We set the Decision of Variant3 to Include. The Status of both Variant2 and Variant3 are now both set to Included. In our validation script, EvaluateConstraint returns False which makes the Variant1 inconsistent. The text we specified as Script.Result is shown the Reason column.