You are viewing limited content. For full access, please sign in.

Question

Question

Set default value to current year

asked on May 4, 2016

Is there a way to set the default value of a field to be the current year?  

  • The field is defined as a type of Integer.  
  • Multiple values are not allowed
  • The following constraint is defined ... ">=1985 & <= 2050"
  • The field is required.

 

We are using Laserfiche Version 10.0

0 0

Answer

SELECTED ANSWER
replied on May 4, 2016

Hi Gene,

I looked a bit more and realized I have a better answer for you. The %(date) token can be used as a default value and automatically provides the current date. Ordinarily that's the full date, but if your Year field is formatted to only show the current year (field format 'y'), then only the current year will be displayed. See https://www.laserfiche.com/support/webhelp/laserfiche/10/en-us/administration/#../Subsystems/LFAdmin/Content/Custom_Date_Time_Field_Display.htm for more information on that. 

One thing to note is that this requires a date field, not an integer field. Is there a reason you need this to be an integer field? If it's just that you only wanted to display the year and not the rest of the date, using the 'y' field format will address that as well. 

2 0

Replies

replied on May 4, 2016

This is really easy to do manually - in the administration console, you can provide a default value for any field there. See https://www.laserfiche.com/support/webhelp/Laserfiche/10/en-US/administration/#../Subsystems/LFAdmin/Content/Setting_a_Default_Field_Value.htm  for more information. There isn't a specific way to do this dynamically although it could certainly be done through a recurring SDK or Workflow script. 

0 0
replied on May 4, 2016

What do you mean by "manually"?  Are you suggesting to just hard code the default value to "2016" and then change it at the beginning of each year?

0 0
replied on May 4, 2016

Right, hard-coding it would be really easy to do. If you want it to dynamically update, you can set up a script that updates each year.

0 0
replied on May 4, 2016

Well, its not the answer I was hoping for but since it is the correct answer I will mark it as such.

0 0
SELECTED ANSWER
replied on May 4, 2016

Hi Gene,

I looked a bit more and realized I have a better answer for you. The %(date) token can be used as a default value and automatically provides the current date. Ordinarily that's the full date, but if your Year field is formatted to only show the current year (field format 'y'), then only the current year will be displayed. See https://www.laserfiche.com/support/webhelp/laserfiche/10/en-us/administration/#../Subsystems/LFAdmin/Content/Custom_Date_Time_Field_Display.htm for more information on that. 

One thing to note is that this requires a date field, not an integer field. Is there a reason you need this to be an integer field? If it's just that you only wanted to display the year and not the rest of the date, using the 'y' field format will address that as well. 

2 0
replied on May 4, 2016

This is the answer I was looking for!  Thanks.

0 0
replied on May 4, 2016

What do you mean by "manually"?  Are you suggesting to just hard code the default value to "2016" and then change it at the beginning of each year?

You are not allowed to follow up in this post.

Sign in to reply to this post.