Search these areas:
Support Forums
Product Info

-DataWeb: What's New
-Creating an Application
-The DataWeb Designer
-Application Management
-Data Tables
-Data Tables
-Data Analysis
-Object Model
-Full-Text Search
-Domain and Email Hosting
-HotBlock Modules
-Account Management
-New Responsive UI Module

DataWeb Help
Support Forums
Script Library
Knowledge Base

Home > Support


How To: Set a field's default value
Article TypeHow To
TitleSet a field's default value
<i>How do I set the default value for a field?</i><br>
The answer to this question depends on whether you want to set a default value regardless of where inserts are made from or if your default value is view-specific.<br>
To set a default value regardless of how data is inserted into a table, write a script in the table's <a href="">BeforeInsert Data Class</a>.<br>
For example, to set the default value of the <span class="smallCode">state</span> field to "WA":<br>
<span class="smallCode">// If the user does not specify a state, set state to WA<br>
if ( !record.state ) { record.state = "WA"; }</span><br>
To set a default on a specific view form, write a <a href="/default.view?Topic=views/vaddingscripts">script on that view</a> inside a dataregion. Make sure you place the htmlblock <i>before</i> the field whose default value you're setting.<br>
<span class="smallCode">&lt;ws:htmlblock displaymodes="insert"><br>
&lt;!--#record.state = "WA";#--><br>
&lt;ws:field name="state" displaymodes="insert">&lt;ws:caption>State:&lt;/ws:caption>&lt;/ws:field></span>
Last ReviewedFebruary 20, 2015 14:08:26

Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
DataWeb, 720 North 10th Street, A #145, Renton, Washington 98057 *425-583-5970* Fax 484-770-4706* Email Us