8/13/2025 2:32:39 PM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
|
|
|
|
Reverting a value on failed validation - How?
Posted: 02 Oct 08 10:34 AM
|
Hey guys,
I've put some additional validation around the Status picklist on Opportunity Details, which fires in the OnChangeAction. The problem I'm having is that I want the value to revert back to what it was (i.e. the saved value) if the validation is failed. I've tried to achieve this by putting either the Refresh Data business rule or the Reset Entity business rule in the OnFail action of my ValidationBusinessRule. Neither of them seem to do anything though; the page refreshes, but the picklist still retains it's value, and there's the thing in the bottom left corner saying changes unsaved. Querying the database at this point reveals that indeed the picklist value which failed validation is not saved to the database, but how do I revert the field in the client back to it's stored value? Note that at the point of the validation check, the value of opportunity.Status is already that of the new, non-validated status, and I don't know how to expose the old, saved value.
Two options spring to mind though neither is particularly elegant: a) Place a hidden field on the form to hold the old value. Use a C# snippet in the OnFail to copy this value back into the Status picklist. b) Invoke a duplicate instance of the current opportunity object (which should use the stored values) during validation. On failure, copy opportunity.Status from the newly-invoked instance to the current one.
I'm hoping there's a better alternative to these two.
Thanks! |
|
|
|
Re: Reverting a value on failed validation - How?
Posted: 02 Oct 08 2:08 PM
|
Hi Alec,
Did you know that there is a WhenBeforeChange event on Properties? This event passes an "args" object that has the before and after values. If you fail validation, you can throw an error and reset the value to the before value.
Stephen www.slxmaster.com
|
|
|
| |
|
Re: Reverting a value on failed validation - How?
Posted: 06 Oct 08 7:48 AM
|
Thanks guys, helpful advice as always!
I was stuck on the idea of trying to change the picklist value back, when I should instead have been looking to correct the entity itself. Using the ChangeManagement interfaces made this very easy! |
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|