Hi OPA Experts,
I have above data model. How to write rules to check FS Agreement Terms , Type , if it is 'Equipment' then pick 'Percentage' from MilestonesForTerms child IC and assign to variables.like below:
"the equipment type percentage" should have value 25
"the service type percentage" should have value 20
I have tried ForAll statement, but it boolean True or False. How to assign to above variables?. thanks.
If you want to assign a value from a sub-entity, you must be able to narrow your definition to one possible entity.
In your example above, you cannot evaluate "the equipment type percentage" if there is more than one "FsAgreementTerm" enity which has a type of Equipment.
Here is the way I would do it:
Assuming the "Quote" is global, although that doesn't really matter.
The quote has an attribute "The equipment type percentage"
Entity "FsAgreementTerm" is contained by global by the relationship "the ListOfFsAgreementTerms"
The FSAgreementType has a attribute the agreement term type corresponding to "<type>"
Entity "MilestoneForTerm is contained by "FsAgreementTerm" by the relationship "the ListOfMilestonesForTerms"
The MilestoneForTerm has an attribute "the percentage" corresponding to "<Percentage>"
The agreement term percentage = InstanceValueif(the ListOfMilestonesForTerms, the percentage, the percentage is known)
The equipment type percentage = InstanceValueif(the ListOfFsAgreementTerms, The agreement term percentage, the agreement term type = “Equipment”)
The first rule lifts the percentage value of MilestoneForTerm up to the FsAgreementTerm parent entity. This will work if the the FsAgreementTerm has one and only one MilestoneForTerm. If there are none or more than one then the result will be unknown or uncertain.
The second rule lifts the percentage value of FsAgreementTerm (evaluated from rule 1) to the attribute "The equipment type percentage". This will work if there is one and only one FsAgreementTerm with the type equipment.
For more information search our documentation for "InstanceValueif"
Note: order is not important, rules are executed in their logical order, not the order they are written in
Hope this helps.