Sales

Get Involved. Join the Conversation.

Topic

    Damien Martin-Prével
    FlexField - Validators - how Boolean are managed in the...
    Topic posted November 13, 2019 by Damien Martin-PrévelRed Ribbon: 250+ Points, tagged Customer Data Mgmt, Groovy, Setup and Maintenance, UX 
    16 Views, 2 Comments
    Title:
    FlexField - Validators - how Boolean are managed in the Groovy expression
    Summary:
    I would like to use a boolean flexfield in a groovy expression
    Content:

    Hello,

    Imagine 2 flexfields :

    • "Flag" is TRUE_FALSE
    • "Type" has a value set (having 4 values possible : H, B, N or L, each value having a specific functional signification)

    I want to create a Validator in order to raise an error with the following rule:

    • If the Type is H or B or L and Flag is false, prompt the error 'Error Message'.

    I thought it easy and so the expression is :

    (FlexSeg?.Type == 'H' || FlexSeg?.Type == 'B' || FlexSeg?.Type == 'L') && FlexSeg?.Flag == false

    It is a valid expression but it prompt the error all the time.

    Other working test : FlexSeg?.Type == 'H' prompt the error only if the Type = H in the UI

    How should I write the expression to validate the rule?

    thanks for your help

     

    Version:
    19C

    Comment

     

    • Fernando Paes

      Hi Damien,

      have you tried FlexSeg?.Flag == 'N' || nvl(FlexSeg?.Flag, '') == ''

      Maybe you can use some println to see what is the exact value of FlexSeg?.Flag, something like println("Flag = " + FlexSeg?.Flag)

      Kind Regards

    • Damien Martin-Prével

      Thanks to the comment of Fernando, I got the final solution... even if it is a Boolean,  the value is stored as a string in the database...

      ((FlexSeg?.Type =='H' || FlexSeg?.Type =='B'|| FlexSeg?.Type =='L') && (FlexSeg?.Flag =='true' || FlexSeg?.Flag =='Yes')) || !(FlexSeg?.Type =='H' || FlexSeg?.Type =='B'|| FlexSeg?.Type =='L')