Search code examples
c#xaf

Setting a value to a field in XPO


If I want to assign a default value to a BO's field while saving it (in my Controller class), How can I achieve this using C# and xaf? Which events are relevant?


Solution

  • I solved the issue by adding this code to my overriden save methods:

        private void ProcessSelectedObject(System.Collections.IList list)
        {
            foreach (object obj in list)
            {
                if (obj is Contact)
                {
                    if (((Contact)obj).Sector == null)
                    {
                        ((Contact)(obj)).Sector = "Default";
                    }
                }
            }
         }