Announcement

Collapse
No announcement yet.

formula break, exit, return??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • formula break, exit, return??

    Hi,

    Is there a way to force an exit on a formula?

    I could nest the code in conditionals, but the code would be simpler if a certain set of conditions were true, stop processing the formula.

    Thanks,
    Russ

  • #2
    Hi,

    No such at this moment. Maybe in future.

    Comment


    • #3
      Hello Yuri,
      do you think, as formula is beforeSave and https://github.com/espocrm/documenta...or-handlers.md

      we can just do a global formula ?
      if yes, it's easy to make a new formula.
      if no...

      Kind Regards

      Comment


      • #4
        Hi all, bumping this because I need something like this.

        How do you guy stop the formula from running?

        I want no more formula to run when "Status==Closed", because the Case is closed...

        I see some potential option but I'm not sure if it will work properly and break the formula all together...

        I tried this idea but doesn't seem like it the way to go. Maybe I should use "when"? But not sure how to use the Break part:


        Code:
        //STOP AND DISABLE FORMULA
        if (type!='Closed'){​
        
        write my formula here
        
        } // STOP FORMULA DUE TO CLOSE STATUS

        Comment


        • #5
          Code:
          while (true) {
              if (some_condition) {
                  break;
              }
          
              if (some_condition) {
                  break;
              }
          
              // some_final_logic
          
              break; // important
          }
          ​
          Last edited by yuri; 04-15-2023, 09:11 AM.

          Comment


          • #6
            Sorry to be a nuisance but is it literally 'break'? Something like this will work?

            I just notice I used 'type!='Closed' in my first post, maybe that why it didnt work.

            Secondly I notice that I have to do this twice when using while formula, would a "if" formula be more ideal?

            Code:
            while (true) {
            if (status!='Open') {
            description='formula is running';
            }
            
            if (status='Closed') {
            description='formula is stop running';
            break;
            }
            
            // some_final_logic
            
            break; // important
            }

            Comment


            • #7
              Update, upon seeing the error above, I went with this formula if anyone want to use it.

              It a very basic formula being use and I don't know if it will always work as I hope it to be... maybe you see an update post some week or months in the future when I run into problem!

              Nothing change except the correct field/attribute (previously I wrote "type" for some reason). So as long as my Status does not equal to "Closed", the formula will executed. When it become Closed it will no longer executed.

              Code:
              //STOP AND DISABLE FORMULA
              if (status!='Closed'){​
              
              // I write my formula here for example:
              description='hey it working'
              
              } // STOP FORMULA DUE TO CLOSE STATUS​
              Last edited by espcrm; 04-17-2023, 08:19 AM.

              Comment

              Working...
              X