+ Start a Discussion
Anca MosoiuAnca Mosoiu 

For speedy data entry, I'd like a new, blank form to load after I've submitted the data

Hi there,

I have a custom object, and created a Visualforce page to make it easy for people to add new records for this object.  After submitting the form, the user is taken to the page for that new object.  What I'd like to do is take them to a new, empty form so they can quickly and easily enter an additional record.  

I tried to use the "oncomplete" attribute on my command button, but it's not working.  What am I missing?

Thanks in advance! 

Here's the code:
 
<!-- Typeahead form plus saving / updating -->
<apex:page standardController="Book__c" showHeader="false" sidebar="False" title="Receive a Book">

   <script type="text/javascript">
   function reloadme(){
       window.location.href="https://c.na17.visual.force.com/apex/EBCBP_Receive_Books?sfdc.tabName=01ro0000000Wc30";
   }
   </script>
   
   <div class="messages"> 
    <apex:messages />
   </div>
   
    <apex:form target="_self">
    
    <div class="entry-form">
        <img src="http://eastbaychildrensbookproject.org/new/wp-content/uploads/2012/07/ebcbp_headergraphic.png"/>
        <h1>Welcome to the East Bay Children's Book Project</h1>
        <p>If you've received books from us before, please proceed below.  Otherwise, go <a href="http://www.eastbaychildrensbookproject.org/kiosk/new-client/">Here</a></p>
        <h3>Your Name:</h3>
        <c:Typeahead secondaryField="Email" placeholder="Enter name or email" minSearchLength="3"
            destinationForSelectedId="contactId"/> 

        <h3>Organization:</h3>
        <c:Typeahead searchBoxId="acctSearchBox" object="Account" primaryField="Name" secondaryField="BillingCity" 
                searchScope="NAME" placeholder="Enter organization name..." minSearchLength="3" 
                destinationForSelectedId="accountId" destinationForSelectedValue="accountName" stealFocus="false" />  

        <h3>Books Received</h3>
        <apex:inputField value="{!Book__c.Number_Received__c}"/>

        <h3>Date Received</h3>
        <apex:inputField value="{!Book__c.DateReceived__c}" />

        <apex:inputHidden value="{!Book__c.Organization__c}" id="accountId"/>
        <apex:inputHidden value="{!Book__c.Person__c}" id="contactId"/>

        
        <input type="hidden" name="accountName" id="accountName" />     

        <apex:commandButton action="{!save}" value="Save" oncomplete="reloadme()"/>


    </div>
    </apex:form>

</apex:page>

 
Best Answer chosen by Anca Mosoiu
Vivek DeshmaneVivek Deshmane
Hi Anca,
If above code will not works then you can refer followng link and let me know.

http://salesforce.stackexchange.com/questions/3907/redirecting-back-to-original-page-using-visualforce

Best Regards,
-Vivek

All Answers

Vivek DeshmaneVivek Deshmane
Hi,
Try below code and let me know if it works for you
<!-- Typeahead form plus saving / updating -->
<apex:page standardController="Book__c" showHeader="false" sidebar="False" title="Receive a Book">

   <script type="text/javascript">
   function reloadme(){
       window.location.href="https://c.na17.visual.force.com/apex/EBCBP_Receive_Books?retUrl=/apex/EBCBP_Receive_Books";
   }
   </script>
   
   <div class="messages"> 
    <apex:messages />
   </div>
   
    <apex:form target="_self">
    
    <div class="entry-form">
        <img src="http://eastbaychildrensbookproject.org/new/wp-content/uploads/2012/07/ebcbp_headergraphic.png"/>
        <h1>Welcome to the East Bay Children's Book Project</h1>
        <p>If you've received books from us before, please proceed below.  Otherwise, go <a href="http://www.eastbaychildrensbookproject.org/kiosk/new-client/">Here</a></p>
        <h3>Your Name:</h3>
        <c:Typeahead secondaryField="Email" placeholder="Enter name or email" minSearchLength="3"
            destinationForSelectedId="contactId"/> 

        <h3>Organization:</h3>
        <c:Typeahead searchBoxId="acctSearchBox" object="Account" primaryField="Name" secondaryField="BillingCity" 
                searchScope="NAME" placeholder="Enter organization name..." minSearchLength="3" 
                destinationForSelectedId="accountId" destinationForSelectedValue="accountName" stealFocus="false" />  

        <h3>Books Received</h3>
        <apex:inputField value="{!Book__c.Number_Received__c}"/>

        <h3>Date Received</h3>
        <apex:inputField value="{!Book__c.DateReceived__c}" />

        <apex:inputHidden value="{!Book__c.Organization__c}" id="accountId"/>
        <apex:inputHidden value="{!Book__c.Person__c}" id="contactId"/>

        
        <input type="hidden" name="accountName" id="accountName" />     

        <apex:commandButton action="{!save}" value="Save" oncomplete="reloadme()"/>


    </div>
    </apex:form>

</apex:page>

Best Regards,
-Vivek
Vivek DeshmaneVivek Deshmane
Hi Anca,
If above code will not works then you can refer followng link and let me know.

http://salesforce.stackexchange.com/questions/3907/redirecting-back-to-original-page-using-visualforce

Best Regards,
-Vivek
This was selected as the best answer
Anca MosoiuAnca Mosoiu
Thanks Vivek!  I didn't really understand what was happening at the stack exchange page above the first time I looked at it.

I tried the initial suggestion you provided, but it looks like the commandButton action didn't want to do the reload.  When I changed the command button to this, it works:
 
<apex:actionFunction name="saveActionFunc" action="{!Save}" oncomplete="reloadme()" />
        <apex:commandButton value="Save" onClick="saveActionFunc();"/>

Thanks so much for your pointers!

Anca.