Default Field Values

Posts   
 
    
quentinjs avatar
quentinjs
User
Posts: 110
Joined: 09-Oct-2009
# Posted on: 08-Dec-2009 06:14:33   

I have a few questions related to setting default values.

I did find this reference to using the code blocks within the generated classes, http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3194

I have a strong resistence to playing in generated classes and prefer methods like partials or using OnEvent methods.

Is it possible to set values: * OnCreate (default field values use) * OnSave (just before save)

On Create would set things like "Assigned Manager" or Expected Shipping Date.

OnSave would need a property to know its Insert or Update. If New/Insert then I want to set the CreateDate = Now and CreatedBy = XXXXXX. And then if its an Update, the ModifedDate = Now and ModifiedBy = XXXXXX

So other then adding my code to the generated code is there an example that shows how this can be done?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 08-Dec-2009 08:36:06   

Similar question was asked here: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=15323

Personally I would use a Validator, Dynamicaly Injected into the entities. Where I can use ValidateEntityBeforeSave to set the default values just before saving.

quentinjs avatar
quentinjs
User
Posts: 110
Joined: 09-Oct-2009
# Posted on: 11-Dec-2009 16:44:29   

So to be clear either set the default values in the **onInitialize **or in the **onValidate **Events ?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Dec-2009 18:08:35   

Exactly simple_smile

David Elizondo | LLBLGen Support Team