You need to sign in to do that
Don't have an account?
Action Region to avoid validation error also losing data on rerender
I have a situation where I have an optional lookup (PO Line Item) and a master detail field (Sub Account) on an Invoice record. The PO Line Item object also links to a Sub Account and I want to default this Sub Account value from a selected PO Line Item into the Invoice's Sub Account field. You don't always have to choose a PO Line Item; in the case that there is no PO you simply select a Sub Account manually.
To accomplish this I have an actionSupport component that calls a controller method onchange to run SOQL on the selected PO Line Item to pull its Sub Account into the invoice's Sub Account field. The user is picking a PO Line Item before they have set a Sub Account, thus that MD field is blank when they select a PO Line Item. This gives a validation error when the action function runs.
To avoid the error, I added ActionRegion tags around the PO Line Item field so that only the PO Line Item value is sent. But this means the rest of the data that I have entered so far is lost in the rerender.
Any thoughts on how to accomplish this - avoid the error on requiring a value in an MD field but keep the values in all the other fields after the rerender?
That's about the only way to do it I'm afraid - if you rerender any other part of the form the value from the controller will be used which will discard any user input as that hasn't been submitted yet.