0

I don't want there to be any conditions (like onchange or onclick), and I only need it to rerender once, which is why I've tried using the timeout attribute.

<apex:page standardController="Account">
<apex:pageMessages />
<apex:messages />
<apex:sectionHeader title="Account Edit" subtitle="{!Account.name}"></apex:sectionHeader>
<apex:form id="theform">
<script>
onload();
</script>
<apex:pageBlock mode="edit" id="thepageblock" title="Account Edit">
<apex:actionFunction name="onload" rerender="thepageblock" timeout="600"/>

It does work sometimes, but more often than not, it doesn't. I need the page to always rerender so that a new Account Type can always be chosen depending on the new Record Type selected.

I've tried rerendering the page, the form, the page block, an outputpanel around the Type field, changing the timeout attribute, etc.

<apex:pageBlockSection rendered="{!IF(Account.RecordType.Name='Client',true,false)}">

         <apex:inputfield value="{!Account.RecordTypeid}" id="RType">

                </apex:inputField>
    <script>

    if ("{!$CurrentPage.parameters.RecordType}" !== "") {
    document.getElementById('{!$Component.RType}').value = "{!$CurrentPage.parameters.RecordType}";

    }
    </script>






            <apex:inputField value="{! Account.Type }">
2
  • I ended up writing an extension to solve my problem, but would still love to know if there's an answer to this question that fulfills my criteria.
    – user34868
    Jun 18, 2017 at 10:47
  • An apex extension or controller is the recommended solution, typically using the action attribute of the apex:page tag. I wonder what problem you're solving, though; there's probably an easier way to do whatever it is you're trying to do. Jun 18, 2017 at 16:34

1 Answer 1

1

If you want to re-render when a field changes this is the conventional pattern:

<apex:pageBlockSection id="x" ...>
     <apex:inputfield value="{!Account.RecordTypeid}">
         <apex:actionSupport event="onchange" reRender="x"/>
     </apex:inputField>
     <apex:inputField value="{!Account.Type}"/>
</apex:pageBlockSection>

The logic relating to the "RecordType" parameter can be handled in your controller.

1
  • I don't - unless there's a way to change the field automatically (as opposed to setting it immediately, like I have) and have that work with the onchange function. I'd prefer the rerender to be unconditional.
    – user34868
    Jun 18, 2017 at 10:10

You must log in to answer this question.