October 13, 201015 yr 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?
October 13, 201015 yr 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().
October 13, 201015 yr Author 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?
October 13, 201015 yr 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.
October 13, 201015 yr 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.
October 13, 201015 yr Author 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.
October 14, 201015 yr Author 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.
Create an account or sign in to comment