I have a custom page, and it has a field which is inline editable. If the value of the field is changed to null, an apex page message is displayed, the logic of which is written in the controller:

if(flag==1) {
   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Invalid Value'));
   return null;
else {
   database.update(List, true);
return new PageReference(
   isSubmitter ?
      UrlModel.SubmitterMenuUrl(ActiveSubMenu, ActiveTile, Id) :
      UrlModel.PubMenuUrl(ActiveSubMenu, ActiveTile, PubId)

When the page message is displayed on the page, the field also shows a null value. What I want is for the previous value of the field to be displayed along with the page message. Is that possible?


By "previous value" I assume you mean the person has arrived to the page by clicking edit, and that the form is already populated with valid data.

This would mean that there is some object somewhere maintaining that state. (Are you using a standard controller? Or a controller extension? Code snippet doesn't make this clear)

Anyway, before you return null (line 3) you could reset the object (or just the field) by re-querying the field. Or better yet, take it from a copy you made in the controller constructor.

As an aside, what you're trying to do might lead to some confusing UX. The error message says "Invalid Value" but the field has the old, valid value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.