Create a Rule Review window
- Last UpdatedOct 15, 2026
- 3 minute read
To demonstrate the use of the RuleReviewControl, you can create an example window. Copy the following code into a new file named RuleReview.pmlfrm and make sure this file is available in the PMLLIB path.
To show the window, enter the following in the command window:
show !!RuleReview
The Rule Review window only generates if the current element has a rule set reference available. For more information, see Rule Set Reference.
----------------------------------------------------------------------
--
-- Copyright 1974 to current year. AVEVA Solutions Limited and its subsidiaries. All rights reserved in original code only.
--
-- File: RuleReview.pmlfrm
-- Type: Form Definition
-- Author: user.name
-- Created: 21/05/2026
--
-- Description: Form to demonstrate Rule Review PMLNet gadget
--
------------------------------------------------------------------------
import 'RuleReviewControl'
handle (1000, 0)
-- Already imported, safe to ignore
elsehandle any
write !!error.text
endhandle
import 'Aveva.Core.Editors'
handle (1000, 0)
-- Already imported, safe to ignore
elsehandle any
write !!error.text
endhandle
layout form !!ruleReview dialog resize size 50 20
using namespace 'Aveva.Core.Presentation'
!this.formTitle = 'Rule Review'
!this.initCall = '!this.init()'
frame .buttonFrame panel anchor left+right+top width 50 height 1.5
button .ce 'CE' tooltip 'Update form with current element' width 4 callback '!this.setCE()'
button .runRule 'Execute Rules' tooltip 'Execute all rules for current element' at xmax.ce + 2 width 10 callback '!this.runRules()'
button .report 'Report' tooltip 'Display a report of the rules in the command window' at xmax.runRule + 2 width 10 callback '!this.report()'
exit
frame .reviewFrame 'Rule Review' at xmin.buttonFrame ymax.buttonFrame anchor left+right+bottom width 50 height 20
container .ruleReviewContainer nobox PMLNetControl dock fill
exit
member .ruleReviewControl is RULEREVIEWCONTROL
member .currentElement is DBREF
exit
------------------------------------------------------------------------
--
-- Method: .ruleReview
--
-- Description: constructor
--
------------------------------------------------------------------------
define method .ruleReview()
using namespace 'Aveva.Core.Presentation'
!this.ruleReviewControl = object RULEREVIEWCONTROL()
!this.ruleReviewContainer.control = !this.ruleReviewControl.handle()
-- for some reason, the C# control doesn't respect the dock fill from the container in form layout
!this.ruleReviewControl.setDock(true)
endmethod
------------------------------------------------------------------------
--
-- Method: .init
--
-- Description: Init Method
--
------------------------------------------------------------------------
define method .init()
!this.setCE()
endmethod
------------------------------------------------------------------------
--
-- Method: .setCE
--
-- Description: Callback for setCE button. Refresh the form with current CE
--
------------------------------------------------------------------------
define method .setCE()
!this.currentElement = !!ce
!a[1] = !this.currentElement.name
!this.ruleReviewControl.InitRuleReview(!a)
endmethod
------------------------------------------------------------------------
--
-- Method: .runRules
--
-- Description: Callback for execute rules button. Execute the rules to set attributes
-- on the element, and refresh the property grid.
--
------------------------------------------------------------------------
define method .runRules()
using namespace 'Aveva.Core.Editors.Converters.RulesEngine'
!rulesEngine = object NETRULESENGINE()
!rulesEngine.executeAllRules(!this.currentElement.name)
!a[1] = !this.currentElement.name
!this.ruleReviewControl.InitRuleReview(!a)
endmethod
------------------------------------------------------------------------
--
-- Method: .report
--
-- Description: Callback for report button. Output some results from the rule check to the
-- command window.
--
------------------------------------------------------------------------
define method .report()
using namespace 'Aveva.Core.Presentation'
-- C# NetRuleReview object
!ruleReview = !this.ruleReviewControl.ruleReview()
!keys = !ruleReview.keys()
!descriptions = !ruleReview.ruleDescriptions()
!results = !ruleReview.results()
write('')
write('----------------------------------------------------------------------')
!ruleLine = 'Rules for ' & !this.currentElement.flnm
write(!ruleLine )
write('')
do !i indices !keys
if (!results[!i].eq(0)) then
!result = 'None'
elseif (!results[!i].eq(1)) then
!result = 'Pass'
elseif (!results[!i].eq(2)) then
!result = 'Accepted'
elseif (!results[!i].eq(3)) then
!result = 'Warning'
elseif (!results[!i].eq(4)) then
!result = 'Fail'
endif
!line = !descriptions[!i] & ' (' & !keys[!i] & ') - ' & !result
write(!line)
enddo
write('----------------------------------------------------------------------')
write('')
-- To run the rule review without the control, use the following code:
-- using namespace 'Aveva.Core.Presentation'
-- !netRuleReview = object NETRULEREVIEW()
-- !a[1] = !!ce.name
-- !netRuleReview.runReview(!a)
endmethod
The code generates the Rule Review window.
