Boolean & Formula with IfThenElse

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dodom2
    Senior Member
    • Jan 2020
    • 198

    Boolean & Formula with IfThenElse

    Hello All. Can someone assist with this formula below:

    ifThenElse(
    status == "Reconciled Transaction",
    entity\setAttribute('reconciled', true),
    entity\setAttribute('reconciled', false)
    );

    "reconciled" is a boolean field. this doesn't work for me. How should I set correctly to check the boolean if this condition is true or make it uncheck if the condition isn't met?
  • eymen-elkum
    Active Community Member
    • Nov 2014
    • 472

    #2
    Hello,

    Try this:

    PHP Code:
    ifThenElse(
        status == "Reconciled Transaction",
        reconciled = true,
        reconciled = false
    ); 
    
    CEO of Eblasoft
    EspoCRM Expert since 2014
    Full Stack Web Developer since 2008
    Creator of Numerous Successful Extensions & Projects​

    Comment


    • dodom2
      dodom2 commented
      Editing a comment
      Thank you Eymen however I tried this already as well and it doesn't work.

    • Maximus
      Maximus commented
      Editing a comment
      What if:
      PHP Code:
      ifThenElse(
          status == "Reconciled Transaction",
          reconciled = 1,
          reconciled = 0
      ); 
      
  • peterberlin
    Active Community Member
    • Mar 2015
    • 1004

    #3
    Hello

    Hello, what is the best way to query a Boolean field with a formula? field name =='1'; field name == 1; field name != null; field name != ''; Peter

    Comment


    • dodom2
      dodom2 commented
      Editing a comment
      Thank you Peter however I had no luck with your post. I tried that before posting here but couldn't really make sense of the resolution.
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1618

    #4
    Try to make ifThen function:

    ifThen(
    status == 'Reconciled Transaction',
    entity\setAttribute('reconciled', true)
    );

    and give the boolean a default of false (in field configuration of entity). That means, that the field is alway false by default and only true, when condition of ifThen is met.

    Comment


    • dodom2
      dodom2 commented
      Editing a comment
      No luck
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1618

    #5
    I tested this here and it works

    Code:
    ifThenElse(
    status == 'Reconciled Transaction',
    entity\setAttribute('reconciled', true),
    entity\setAttribute('reconciled', false)
    );
    Only to be sure: Did you recalculate formula in your entity? Sometimes rebuild helps as well as purging the browser cache.

    The formula above is correct.

    Comment

    Working...