This discussion is archived
2 Replies Latest reply: Oct 25, 2013 1:52 AM by ParthibHW RSS

Writing rules to store instance entity value to variable

ParthibHW Newbie
Currently Being Moderated

Hi OPA Experts,

 

<QuoteIO xmlns="http://www.siebel.com/xml/Quote%20OPA">

  <Quote>

    <ListOfFsAgreementTerms>

      <FsAgreementTerms>

        <Type>Equipment</Type>

        <ListOfMilestonesForTerms>

          <MilestonesForTerms>

            <Percentage>25</Percentage>

          </MilestonesForTerms>

        </ListOfMilestonesForTerms>

      </FsAgreementTerms>

      <FsAgreementTerms>

        <Type>Service</Type>

        <ListOfMilestonesForTerms>

          <MilestonesForTerms>

            <Percentage>20</Percentage>

          </MilestonesForTerms>

        </ListOfMilestonesForTerms>

      </FsAgreementTerms>

    </ListOfFsAgreementTerms>

  </Quote>

</QuoteIO>

 

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.

  • 1. Re: Writing rules to store instance entity value to variable
    frank.hampshire Expert
    Currently Being Moderated

    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:

     

    The datamodel

     

    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 rules

     

    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.

     

    Cheers

    Frank

  • 2. Re: Writing rules to store instance entity value to variable
    ParthibHW Newbie
    Currently Being Moderated

    Hi Frank,

     

    Excellent. clear and concise explanation. Thanks a lot. It works.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points