Ticket Q475272
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Filtering - Create a built-in criteria function to check if an XPO object is new or saved

Disable modify after persistant object is stored in the database

created 12 years ago

I would like to get some direction on if and how its possilbe to prevent a property from being modified after its save to the databases.
In my products table I have Fields like Color that the user can not change after the product was created.
I believe this is a validation rule but not sure how to approach it in XAF

Also I would appreciate any andswer with code to be in VB.NET
thank in advance
David Raschka

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hello Grigor,
You can use the Conditional Appearance module for this. Add this module to your project and apply the rule shown in the Conditional Appearance rule for a new object ticket to the required business class.

    Show previous comments (2)
    Anatol (DevExpress) 12 years ago

      First, return an inverted value in the IsNewObject method:

      Visual Basic
      <Appearance("DisableColor", AppearanceItemType:="ViewItem", context:="DetailView", enabled:=False, TargetItems:="Color")> _ Public Function IsSavedObject() As Boolean Return Not Session.IsNewObject(This) End Function

      Otherwise, the Color editor will be disabled for new objects and enabled for saved objects.
      In addition, ensure that you have added the Conditional Appearance module to your project via the Module Designer.
      If this still does not work, please provide a sample project reproducing the problem.

      GT GT
      Grigor Terterian 12 years ago

        Works like a charm!!! - thanks so much - I need to brush up on my C# - forgot ! indicates not
        For other interested , you can put multiple fields in this attribute by using commas in TargetItems:
         <Appearance("DisableColor", AppearanceItemType:="ViewItem", context:="DetailView", enabled:=False, TargetItems:="Color,Style,SupplierID")> _
                Public Function IsNewObject() As Boolean
                    Return Not Session.IsNewObject(This)
                End Function

        Anatol (DevExpress) 12 years ago

          You are welcome!

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.