Why not use this auto-enter calculation?
Year ( Get ( CurrentYear ) )
And not have the user enter this data at all?
I need the above script in place just in case the user is entering historic data, i.e the user maybe entering from a previous year.
I need the script to first off enter the current year
and then carry out the checks as identified in my above script just incase the user changes the year
Any help combining the two scripts would be appreciated
First, this is not a script, it's a calculation. Scripts are created via Manage | Scripts. This is created in the specify calculation dialog box.
If I understand you correctly, you want any year entered that is a future year or more than 10 years in the past to be automatically replaced with the current year?
If that's what you want, you are almost there;Let(@Numbers = GetAsNumber( TextFormatRemove (Filter(Self; "0123456789")));Case(@Numbers < Year(Get(CurrentDate)) - 10 or //checks that the year entered is not over 10 years ago@Numbers > Year(Get(CurrentDate)) ; //checks that the year entered is not higher than the current yearTextColor ( Year ( Get ( CurrentDate ) ) ; RGB(255; 0; 0)) ;@Numbers))Another option is to use the OnObjectValidate script trigger to perform a script that checks the range and then pops up a message notifying the user of the auto-correction with an option to return and try again if this year is not the value that they should be entering.
Thanks PhPhilip ended up using year(get(currentdate)) in the script that opened the new record layout to set the year field to the current year.
Which does exactly what my original suggestion would have done. Auto-entered calculations, as long as the "Do not replace..." option is selected, will enter an initial value when the record is created, but then the user can edit the value to change the "default" value thus entered.