1 Reply Latest reply on Oct 22, 2012 10:43 AM by tengyu ma

    how to return multiple results using single variable of my bean.

    Avneesh Sisodia Newbie

      Hello ,

      I know that this que is very silly type. but I have not any idea how to do it.

      I have a bean which contains some variable i.e. noOfPoliciesSold, totalPremium, noOfDays, avgCertificateCost, pointsCalculated etc.

      I have a rule in guvnor

       

       

      rule "1"
          when 
              AffiliateRankingDataBean( noOfPoliciesSold == 1)
          then
              AffiliateRankingDataBean fact0 = new AffiliateRankingDataBean( );
              fact0.setPointsCalculated(1);
              AffiliateRankingValidateBean bean = new AffiliateRankingValidateBean( );
              bean.setAffiliateRankingBean(fact0);
      end
      
      rule "2"
          when 
              AffiliateRankingDataBean( noOfPoliciesSold == 2)
          then
              AffiliateRankingDataBean fact0 = new AffiliateRankingDataBean( );
              fact0.setPointsCalculated(2);
              AffiliateRankingValidateBean bean = new AffiliateRankingValidateBean( );
              bean.setAffiliateRankingBean(fact0);
      end
      rule "3"
          when 
              AffiliateRankingDataBean( totalPremium < 300000)
          then
              AffiliateRankingDataBean fact0 = new AffiliateRankingDataBean( );
              fact0.setPointsCalculated(2);
              AffiliateRankingValidateBean bean = new AffiliateRankingValidateBean( );
              bean.setAffiliateRankingBean(fact0);
      end
      

       

      Now suppose bean have noOfPoliciesSold=2 and totalPremium =200000 then I want to get PointsCalculated = 4

      (It should fire rule no 2 & 3)

      But my rule is returning PointsCalculated = 2 (only from rule 2, not considering rule 3 )

      please guide me that how I can achieve this result. What modification should I need to do.

        • 1. Re: how to return multiple results using single variable of my bean.
          tengyu ma Newbie

          Hi,

               It fire rule 2 ,PintsCalculated=2 , then fire rule 3, PointsCalculated =2. they are two different objects.

            

              In my opinion, the fact0 should be the Global variable. as follows:

           

             global   packageName.AffiliateRankingDataBean ardb;

           

             rule 1
              when
                  AffiliateRankingDataBean( noOfPoliciesSold == 1)
              then
                  ardb.setPointsCalculated(ardb.getPointsCalculated()+1);
          end

          rule 2
              when
                  AffiliateRankingDataBean( noOfPoliciesSold == 2)
              then
                  ardb.setPointsCalculated(ardb.getPointsCalculated()+2);
          end
          rule 3
              when
                  AffiliateRankingDataBean( totalPremium < 300000)
              then
                  ardb.setPointsCalculated(ardb.getPointsCalculated()+2);
                 
          end

           

          Create ardb in the code :

          AffiliateRankingDataBean ardb=new AffiliateRankingDataBean();

          session.setGlobal(ardb);

          1 of 1 people found this helpful