SOLVED: See my answer below.
I have a VF component on our opportunity detail page where users can enter input values on an apex form. There are multiple apex commandbuttons that produce another VF page rendered as a word document, using the apex form values and opportunity record values. I would like the process to run in this order: enter in values, click button, records save to opportunity, VF page renders as word doc, user remains on the same page.
I have everything working, except the apex commandbutton's standard {!save} action is firing AFTER the VF page renders as the word doc, so the word doc does not contain the apex form values. Is there any way I can execute a standard save action BEFORE the word doc is rendered so all values are passed through?
As of now, this process is successful if users enter form values, click the button, wait for the page to "refresh" with rendered doc, and click the button again. So it's not an issue of the form values not saving, it's the issue of the execution order.
I would like to do this without adding in a controller. Is this possible? I'm open to using "oncomplete" and an actionfunction, but I have been unsuccessful so far in my attempts. Below is my code, any help would be greatly appreciated.
<apex:form id="form" >
<apex:pageBlock >
<apex:outputPanel layout="block" styleClass="custom1">
<apex:pageBlockSection columns="1">
<apex:inputField value="{!Opportunity.Value1}"/>
<apex:inputField value="{!Opportunity.Value2}"/>
<apex:inputField value="{!Opportunity.Value3}"/>
<apex:inputField value="{!Opportunity.Value4}"/>
<apex:inputField value="{!Opportunity.Value5}"/>
<apex:inputField value="{!Opportunity.Value6}"/>
<apex:inputField value="{!Opportunity.Value7}"/>
<apex:inputField value="{!Opportunity.Value8}"/>
</apex:pageBlockSection>
</apex:outputPanel>
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!save}" rerender="none" value="Generate X Proposal" onclick="codeAddress();"/>
<apex:commandButton action="{!save}" rerender="none" value="Generate Y Proposal" onclick="codePlaceholder();"/>
</apex:pageBlockButtons></apex:pageBlock></apex:form>
<script type="text/javascript">
function codeAddress() {
window.open('apex/XProposalDraft?id={!id}');
}
function codePlaceholder() {
window.open('/apex/YProposalDraft?id={!id}');
}
</script>
</apex:page>```