Salesman0Gil Posted October 13, 2010 Posted October 13, 2010 Hello All I have a set variable that is equal to: If(Get ( CurrentTime ) If I have a calc field set to this it works, if I use a variable it does not. The overall program is for a time clock I am developing. The above equation is for people working overnight, and there last punch is actually on a new day, but needs to be on the previous day. I have double checked the "Yesterday Problem" field, and that is working perfectly, and so are the other fields mentioned. Do variables get calculated differently? The calc field had to be "unstored." The variable is not stored either, it is not a global variable, and it is cleared at the end of the script. Any ideas?
TheTominator Posted October 13, 2010 Posted October 13, 2010 Do variables get calculated differently? The calc field had to be "unstored." The variable is not stored either, it is not a global variable, and it is cleared at the end of the script. Variables in scripts are calculated differently from calculated fields in two potentially significant ways. (1) Because they are in scripts, you need to execute the script in the correct context, i.e. layout. A calculated field has an explicit context when you define it. You might be in the wrong context when running a script if you aren't careful about the layout you're on when it is running. (2) Script variables are always text values. This can have some gotchas when doing non-text comparisons unless you explicitly convert the values, e.g. GetAsNumber().
Salesman0Gil Posted October 13, 2010 Author Posted October 13, 2010 I double checked and it is using the correct layout. I thought that may be it at first. Concerning your other point, I understand that the variable result needs to be text, but does every part of the equation? For instance if I have trigger that relies on a field equaling zero, does it need to be the text zero?
comment Posted October 13, 2010 Posted October 13, 2010 Can you explain what exactly doesn't work? With the Advanced version, you can use script debugger and data viewer to see the variable's value at each step.
TheTominator Posted October 13, 2010 Posted October 13, 2010 For instance if I have trigger that relies on a field equaling zero, does it need to be the text zero? Comparisons with zero should be fine. I was thinking along the lines of $myVar is "3" then a text string comparison will yield "3" > "20" since that is how they would be alpha-ordered.
Salesman0Gil Posted October 13, 2010 Author Posted October 13, 2010 The variable should either today name or yesterdays name. When that is determined, it places the punch in the appropriate place. It works great in testing. Something is not working in the wee hours of the morning though. It is boggling me, because all the criteria are met, but it still returns today's name instead of yesterdays.
Salesman0Gil Posted October 14, 2010 Author Posted October 14, 2010 I finally got it! The problem was with one of the fields that was used in the equation. It was not set to not store the data, and to recalculate when needed.
Recommended Posts
This topic is 5524 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now