Populating Default Date Field Values

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

Populating Default Date Field Values

  • Comments 1
  • Likes
This article has been updated.
 
Create Script example

Date/Time fields can can have their values set by using the DefaultType property.

If DefaultType set to 6 then the field displays the Current Date/Time

DefaultType = 6;

If DefaultType set to 14 then the field displays the Current Date/Time plus 30 minutes

DefaultType = 14;

There is always more than one way of doing things.
 
We can find a general discussion of how to handle dates in ASP pages and script files in the article "Add/Subtract Days to a Date and pass to a Record Object".

We can control the initial value of a screen by setting the DefaultValue property.

For example to set a field to the current date plus one week. We can enter the following in the Create script for the date/time field.

var mydate = new Date();
mydate.setDate(mydate.getDate() +7);
DefaultValue = mydate.getVarDate() ;

Workflow example

When working with workflow rules, e.g. Primary and Transition rules we can set Date field values using the "Set Column Value" action.

This action puts a value into a column. To set a Date/Time field to the current date/time then use the value 0. Any other integers entered here are treated as an offset from now. For example

30 = 30 minutes into future
10080 = 7 days into the future
129600 = 90 days (3 months) from now.
Comments
  • Thanks Jeff, just used this 10 years after you posted it! :) Workflow example was exactly what I was looking for. Nice way to avoid hidden SQL scripts and just use the UI. Thanks.