function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
truebruceleetruebrucelee 

Custom edit screen validation blanks out all fields

Hi, I'm having weird problem and can't find or google a solution.

 

I have a custom edit screen for one of my custom objects. As it contais lots of fields I used fields sets to render them on VF page. Sample code:

 

<apex:pageBlockSection title="Details">
<apex:repeat value="{!$ObjectType.objectName.FieldSets.FieldSetName}" var="f">
 <apex:inputField value="{!record[f]}" required="{!f.Required}" />
</apex:repeat>
</apex:pageBlockSection>

I use standardController and extension.

I have a commandButton that runs one of the functions in extension controller. 

 

Simplified constructor method looks like this: 

public ConstructorForClassName (ApexPages.StandardController controller){
    	this.controller = controller;
        this.record= (objectName)controller.getRecord();
}

 I overrode the default New and Edit buttons.

 I populate all fields. One of the fields is a lookup to eg. User. In this lookup I provide a partial name and I know that this partiall name will return me the "more than one exists..." error. I click save. I get the "more than one..." error and all fields blanked out. 

 

I tried to put some debug statements in constructor and in the function that is called on Save button but none of these can be found later in debug logs. It looks like this validation is run before either is called. 

 

Do you have any idea how to keep populated fields values on the screen when this validation error occurs?

 

All class variables are public with {get;set;}. 

When value is proper in lookup, record is saved without any issues. Custom validations that are in controller, even when they are run, the fund state is kept. But somehow this defaut validation error is blocking fields update on the record object in controller.

 

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

There was a bug that was causing input values to be lost when there is a validation error in pages using dynamic (subscripted) references.    This should be fixed very soon.   It isn't entirely clear to me that your problem is exactly the same but I think it is....

 

 

 

 

All Answers

aballardaballard

There was a bug that was causing input values to be lost when there is a validation error in pages using dynamic (subscripted) references.    This should be fixed very soon.   It isn't entirely clear to me that your problem is exactly the same but I think it is....

 

 

 

 

This was selected as the best answer
truebruceleetruebrucelee

Yup, this must be the case. Switching back to hardcoded inputFields solves the issue. It looks like I'll have to remove lookups from fieldsets and define them explicitly on VF page. Thanks aballard.

aballardaballard

(Or hold off for a day or two and see if it gets fixed :-)   )

aballardaballard

The bug I referred to should be fixed now.   Let me know if it did not solve your problem... (if it didn't, you should open a support case...)

truebruceleetruebrucelee

Hahahahaha, I can't believe this. It is working :)