
When a field is changed in the 7.2 web client, you often will find scenarios where you will have business rules that need to validate the change and possibly change it back to whatever it was before. Checking the property on the entity, you’ll find it is too late. The property will already show the new value it was changed to. Fortunately, the 7.2 platform maintains state for all entities, so it is possible to easily retrieve the previous value for a property.
The following code will demonstrate how to gt the entity state for the account entity and retrieve the previous value for a property named MyProperty.
using System.Collections.Generic; //for IDictionary using Sage.Platform.ComponentModel; //for ComponentChange using Sage.Entity.Interfaces; //for IAccount using Sage.SalesLogix.Orm; //for IEntityState //... IDictionary<string, ComponentChange> changes = (account as IEntityState).GetChanges(); if (changes.ContainsKey("MyProperty")) { string oldValue = (string)changes["MyProperty"].OldValue; string newValue = account.MyProperty; // now do whatever you need to do with the oldValue and newValue }
Keep in mind that the OldValue will be returned as an object, you’ll need to cast it into the proper type to use it. Enjoy!
Subscribe To Our Newsletter
Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!
You have Successfully Subscribed!