3 Replies Latest reply: Apr 8, 2014 5:51 PM by Matt Sevin RSS

    Ensure 2 instances exist

    1010199

      Hi All,

       

      I would like to write a rule to ensure 2 instances of an entity were created by the user. My entity is called "the toy", and I want to ensure the user has "the toy = lego" as 1 instance,  and another instance that is the toy = "barbie'. If the user adds the lego as an instance, but not the barbie, in the "Why" decision tree, it should say that the barbie instance was not provided (something to that extent), thus the child does not have the correct toys.

       

      Any idea on how I should write this rule?

       

      Thanks!

        • 1. Re: Ensure 2 instances exist
          Matt Sevin

          Sounds as if you might want to present a list of toys and check whether the person "selected" (as opposed to "created") the two specific instances of toys.  For example, you could define a set of toys such as barbie, legos, etc. and then present a questions asking for "the child's favorite toy" would contain the list of toys. In this scenario a known set of toys exists and the user is selecting from that set and the rule would only need to check whether a specific instance of a toy was among the set selected.   (i.e. ... if Barbie is a member of the child's favorite toys)

           

          If you are really after whether the user "creates" a new instance of a toy with a given name then the rule would have to check the created instances for specific names. Such a rule can be written as well, but becomes more complicated depending on your policies for "acceptable" names tat the user may enter.  For example, consider the user may enter "Barbie" vs "barbie" vs. barbie doll", etc.   In this case your rule would check a similar condition as above or could more specifically refer to the toy's name such as " ... if the toy's name = "barbie" or ... the toy's name = "Barbie", etc.)  

          • 2. Re: Ensure 2 instances exist
            1010199

            Hi Matt,

             

            You are correct, the first paragraph defines what I would like to do. How would I write a rule that checks whether the person "selected" those two specific instances of toys?

            • 3. Re: Ensure 2 instances exist
              Matt Sevin

              The exact language of the rule will be dependent on the phrasings you choose for the entities, relationships and attributes. 

               

              In the simplest form (where "all instances of the toys" is a relationship to global and "the selected toys" is a relationship to global which is asked about on the screen) the rule could take the form of:

              <conclusion> if

              "barbie" is a member of the selected toys AND

              "logos" is a member of the selected toys

               

              The rule will become more complicated if you are reasoning across entities.  For example if you are modeling children as entities and the child's selected toys for each instance of a child.

               

              The most relevant topics in the user guide will be those related to "relationships", reasoning with entities, "is a member of" function and InstanceEquals (i.e. <entity> is <entity>).   There are a number of examples provided for the different rule constructs and functions in both the user guide and the example rule bases.