• NikhilMore
  • NEWBIE
  • 0 Points
  • Member since 2013
  • Senior Programmer
  • Accenture


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I'm trying to display a confirm dialog to the user before executing an update.

 

I've tried the following:

 

<apex:pageBlockButtons > <apex:commandButton action="{!updateAccountsOpportunities}" value="Update" rerender="UpdateAccountsOpportunitiesSuccessMsg, AccountMaintenance" status="AccountsOpportunitiesLoadingStatus" onclick="return confirm('Are you sure you want to update the following records?')" /> <apex:commandButton action="{!cancel}" value="Cancel" immediate="true" /> </apex:pageBlockButtons>

 

I discovered that I could process the update with the confirmation dialog using the actionFunction tag.  However, it causing some other problems.

 

I have three pageBlock sections wrapped in actionRegion tags, so that each pageBlock section will validate and process independently.

 

Once I added the actionFunction tag, the actionRegion no longer functions correctly.  When the page posts back, all three pageBlock sections validate.

 

Here is my VF code:

 

<apex:page Controller="AccountMaintenanceController"> <script> function confirmation() { var answer = confirm('Are you sure you want to update the following records?'); if (answer) { doSave(); } else { return false; } } </script> <h1>Manage Salesperson Territory Assignments</h1> <apex:form id="AccountMaintenance"> <apex:actionRegion > <apex:pageBlock title="Update Account and Opportunity Ownership" mode="edit"> <apex:pageBlockButtons > <apex:commandButton action="{!updateAccountsOpportunities}" value="Update" rerender="UpdateAccountsOpportunitiesSuccessMsg, AccountMaintenance" status="AccountsOpportunitiesLoadingStatus" /> <apex:commandButton action="{!cancel}" value="Cancel" immediate="true" /> </apex:pageBlockButtons> <apex:pageMessages rendered="true" id="UpdateAccountsOpportunitiesSuccessMsg" /> <apex:actionStatus id="AccountsOpportunitiesLoadingStatus"> <apex:facet name="start"> Updating records... <img src="{!$Resource.AjaxLoading}"/> </apex:facet> </apex:actionStatus> <apex:pageBlockSection title="Used to transfer ownership of accounts and opportunities from one sales rep to another" columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel value="Change Owner From" for="old_account_owner" /> <apex:inputField value="{!AccountFrom.ownerId}" id="old_account_owner" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Change Owner To" for="new_account_owner" /> <apex:inputField value="{!AccountTo.ownerId}" id="new_account_owner" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Account Ownership" for="acct_owner" /> <apex:inputCheckbox value="{!acctChkbox}" id="acct_owner" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Opportunity Ownership" for="oppy_owner" /> <apex:inputCheckbox value="{!oppyChkbox}" id="oppy_owner" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Opportunity Email" for="oppy_email" /> <apex:inputCheckbox value="{!oppyEmailChkbox}" id="oppy_email" /> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:actionRegion> <apex:actionRegion > <apex:pageBlock title="Update Specific District or Account Ownership" mode="edit"> <apex:pageBlockButtons > <apex:commandButton value="Update" onclick="confirmation();" /> <apex:actionFunction name="doSave" action="{!updateChildAccountOwnership}" rerender="UpdateChildAccountsSuccessMsg, AccountMaintenance" status="ChildAccountsLoadingStatus" /> <apex:commandButton action="{!cancel}" value="Cancel" immediate="true" /> </apex:pageBlockButtons> <apex:actionStatus id="ChildAccountsLoadingStatus"> <apex:facet name="start"> Updating records... <img src="{!$Resource.AjaxLoading}"/> </apex:facet> </apex:actionStatus> <apex:pageMessages rendered="true" id="UpdateChildAccountsSuccessMsg" /> <apex:pageBlockSection title="Used to update owner of specified account and related child accounts" columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel value="Change Owner To" for="new_account_owner" /> <apex:inputField value="{!AccountToByParent.ownerId}" id="new_account_owner" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="District Account to update" for="account_name" /> <apex:inputField value="{!DistrictAccount.parentId}" id="account_name" required="true" /> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:actionRegion> <apex:actionRegion > <apex:pageBlock title="Update Account Ownership by State" mode="edit"> <apex:pageBlockButtons > <apex:commandButton action="{!updateAccountByState}" value="Update" rerender="UpdateOwnerByStateSuccessMsg, AccountMaintenance" status="StateLoadingStatus" /> <apex:commandButton action="{!cancel}" value="Cancel" immediate="true" /> </apex:pageBlockButtons> <apex:pageMessages rendered="true" id="UpdateOwnerByStateSuccessMsg" /> <apex:actionStatus id="StateLoadingStatus"> <apex:facet name="start"> Updating records... <img src="{!$Resource.AjaxLoading}"/> </apex:facet> </apex:actionStatus> <apex:pageBlockSection title="Used to update owner of accounts by selected state" columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel value="Change Owner To" for="new_account_owner" /> <apex:inputField value="{!AccountToByState.ownerId}" id="new_account_owner" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="State" for="state" /> <apex:inputField value="{!State.State__c}" id="state" required="true" /> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:actionRegion> </apex:form> </apex:page>

 

 

Thanks for any help.

Message Edited by Dman100 on 10-17-2009 09:52 PM