Decision Management (ODM,ADS)

Decision Management (ODM, ADS)

Connect with experts and peers to elevate technical expertise, solve problems and share insights

 View Only
  • 1.  ODM: "Exists" type of expressions in decision tables?

    Posted Mon March 24, 2025 09:20 AM

    Hi y'all!

    I have a question regarding condition columns in a decision table. I need a rule to check if a document contains strings. If one exists and the other not, then fire the rule. There are many of these string pairs, and several pairs may be in a document. 

    I thought a decision table would be the obvious choice. But I need to check the non-existence of the other string in the document, and I can't figure out how to do that. I would like to express something like "there exist no string such that this string is <a string>". 

    Is there even any such syntax for a decision tree condition column?

    Any guidance greatly appreciated.

    Regards, Jan



    ------------------------------
    Jan Andersson
    ------------------------------


  • 2.  RE: ODM: "Exists" type of expressions in decision tables?

    Posted Tue March 25, 2025 03:50 PM

    you cannot use exists operator in a decision table.

    Is it not possible to write the document do not contain <a string>



    ------------------------------
    Alain Robert
    ------------------------------



  • 3.  RE: ODM: "Exists" type of expressions in decision tables?

    Posted Wed March 26, 2025 03:40 AM

    OK thanks. I assume this is not going to change so I need to find another way of solving my problem.

    So just out of curiosity: Is there a reason for this?



    ------------------------------
    Jan Andersson
    ------------------------------



  • 4.  RE: ODM: "Exists" type of expressions in decision tables?

    Posted Fri May 02, 2025 03:10 PM

    Jan,

    Here's a quick workaround - Create a static Java method: static boolean existsStringInDoc(String str, String doc) in a Util class. Import this into your BOM and verbalize as "{0} exists in {1}". In your DT, you can have a condition: it is not true that {0} exists in {1}.

    HTH.



    ------------------------------
    Raj Rao
    Principal Consultant
    RuleScape Consulting LLC raj.rao@rulescape.biz
    ------------------------------



  • 5.  RE: ODM: "Exists" type of expressions in decision tables?

    Posted Tue May 06, 2025 04:28 AM

    Following on from Raj's suggestion. I have a toolkit of such helper methods that I include into many rule projects.
    I find it particularly useful in such use cases as yours to have a 'containsAnyOf' and 'containsNoneOf' as these work very well in Decision Tables. I even have case insensive variations so that I don't miss capitalised words.
    The arguments to the helper methods are 'String source' and a 'String[] targetList' and you can pass a list of strings to search for in the BAL rule e.g. {"one", "two", "three"}

    and the B2X code for containsAnyOf (Case insensitive variant):

    if (source == null || source.equals(""))

        return false;

    for (int item = 0;item < targetList.length; item=item+1 ) {

        if (source.toLowerCase().contains(targetList[item].toLowerCase()) )

           return true;

    }

    return false;

    and the B2X code for containsNoneOf (Case insensitive variant):

    if (source == null || source.equals(""))

        return true;

    for (int item = 0;item < targetList.length; item=item+1 ) {

        if (source.toLowerCase().contains(targetList[item].toLowerCase()) )

           return false;

    }

    return true;



    ------------------------------
    Andy Macdonald
    ------------------------------