3 Replies Latest reply on Aug 11, 2014 6:37 AM by philmodjunk

    How to stop calculation?

    ienalpe28

      Title

      How to stop calculation?

      Post

           I am counting the number of days passed if the field action is empty or not yet acted by this calculation

           DaysPassed = GetWorkDays ( DateReceived ; Get ( CurrentDate ))

           GetWorkDays is a custom function I got from the internet. It count the number of days excluding saturday and sunday.

           What I want is to stop the calculation if the field action is not empty or user already acted.

           With my calculation DaysPassed, it keeps incrementing because I don't know how to stop it when field action is not empty or a user already acted.

           Take note that field action is a related field. 

           Thanks

        • 1. Re: How to stop calculation?
          SteveMartino

               Can you post the entire custom function?

                

          • 2. Re: How to stop calculation?
            ienalpe28
                 Here is the Custom Function with 2 parameters StartDate and DueDate.
                  
                 Int ( ( DueDate - StartDate ) / 7 ) * 5 
                  
                 + 
                  
                 Case
                 DayOfWeek ( DueDate ) < DayOfWeek ( StartDate ) ; 
                 Min ( 5 ; DayOfWeek ( DueDate ) - 1 ) + Max ( 0 ; 6 - DayOfWeek ( StartDate ) ) ;
                  
                 DayOfWeek ( StartDate ) < 7 ; 
                 Min ( 6 ; DayOfWeek ( DueDate ) ) - DayOfWeek ( StartDate ) ; 
                  
                 0 
                 )
            • 3. Re: How to stop calculation?
              philmodjunk

                   I think that you'll need another number field, FinalDaysPassed that is set to the value of this calculation via a set field step in a script. The script can be run from the OnObjectSave Trigger on your action field.

                   Then you dayspassed calculation field can be modified to include an if or case function that returns the value of FinalDaysPassed if the action field is not empty but returns your current calculation if it is empty.