﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Default values upon adding or modifying records...</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 12:01:30 GMT</lastBuildDate><ttl>20</ttl><item><title>Default values upon adding or modifying records...</title><link>http://forum.strataframe.net/FindPost964.aspx</link><description>When I am adding a new record how would I specify a default value for this record? Like say for instance when I add a new record I want the Created field to be set with the current date.  I'm assuming this is something that would be done in the business object just not sure where or how.</description><pubDate>Thu, 27 Apr 2006 09:03:14 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Default values upon adding or modifying records...</title><link>http://forum.strataframe.net/FindPost974.aspx</link><description>That's correct... when they click undo, it cancels any changes within the business object, whether the fields were changed programmatically or through the form :)</description><pubDate>Thu, 27 Apr 2006 09:03:14 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Default values upon adding or modifying records...</title><link>http://forum.strataframe.net/FindPost973.aspx</link><description>Great! Thanks, that works.  &lt;br&gt;
&lt;br&gt;
Question: So if the user edits the record this FieldPropertyChanged event fires and would put the current time in the Modified field.  However, if the user clicks the undo button its as if it never happened.  The value set in the Modified field would never make it back to the database because the save button was never clicked.  Right?</description><pubDate>Thu, 27 Apr 2006 09:01:45 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Default values upon adding or modifying records...</title><link>http://forum.strataframe.net/FindPost972.aspx</link><description>Oops, sorry, FieldPropertyChanged is the event, not FieldValueChanged...&lt;br&gt;
&lt;br&gt;
In the event arguments, we pass the the field that changed, so if you only want to change the Modified field when specific fields are modified, then you can test on which field changed before you set the Modified value.</description><pubDate>Thu, 27 Apr 2006 08:44:30 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Default values upon adding or modifying records...</title><link>http://forum.strataframe.net/FindPost971.aspx</link><description>I selected "Single Event for All Fields" for the "Changed Events" type and clicked Ok inside the properties for the BO. It didnt look like anything changed because I saw no indication that I needed to rebuild the BO, but I did it anyway. Then when I went into the BO the only event handler I saw that was close to FieldValueChanged was FieldPropertyChanged.&lt;br&gt;
&lt;br&gt;
Any ideas?</description><pubDate>Thu, 27 Apr 2006 07:54:21 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Default values upon adding or modifying records...</title><link>http://forum.strataframe.net/FindPost967.aspx</link><description>You'll need to go to the BOMapper and configure the business object.  Inside the configuration, select "Single Event for All Fields" for the "Changed Events" type.  After rebuilding the partial class for the business object, you'll have a new event called FieldValueChanged.  Add a handler to this event (within the business object itself) and within the handler add the line "Me.Modified = DateTime.Now"  Whenever you change a field on the business object, it will go through this event and set the "Modified" field to the current time.  When you save the record, that fieldl will also be updated back to the server.</description><pubDate>Wed, 26 Apr 2006 16:03:44 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Default values upon adding or modifying records...</title><link>http://forum.strataframe.net/FindPost966.aspx</link><description>Great! That works for new records, but what about existing records? Let say I want to update the Modified field with the current date after a user modifies the record.</description><pubDate>Wed, 26 Apr 2006 16:00:10 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Default values upon adding or modifying records...</title><link>http://forum.strataframe.net/FindPost965.aspx</link><description>Within the main code file, you should have a handler for [BOName]_SetDefaultValues().  This event is raised whenever a new record is added to a business object, so within it, add the line "Me.Created = DateTime.Now" and that will do the trick.  You can also set any other default values you need to, and you can pull the default values in whatever means necessary.  For instance, in several cases, we have the default values stored off as "soft" default values within the database (i.e.: the end user can set the default City for new customer records, and when you set the default values, you can pull the default value for City from the business object containing the default values).</description><pubDate>Wed, 26 Apr 2006 15:45:52 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>