You need to sign in to do that
Don't have an account?
SFDC-SD
Custom Account Merge using Billing Address
Hi
I am developing custom account merge page, is there any way I can pass account ids to a JSP by selecting accounts from the list?
https://cs8.salesforce.com/merge/accmergewizard.jsp?goNext&cid={!CID1}&cid={!CID2}&cid={!CID3}
I should be able to select only 2 accounts from list.
Right now I am able to merge two account by dynamically passing the CID1 and CID2 which works fine. My requirement is I should be able to select any of 2 accounts from the list and should be pass the selected account Ids to merge wizard.
Appreciate any help
///***************** Controller *******************/// public class AccountSearchController { //added an instance varaible for the standard controller private ApexPages.StandardController controller {get; set;} // the actual account public Account a; public Account s; pagereference p = null; public string current_Id {get; set;} public string sid1 {get; set;} public string sid2 {get; set;} public List<Account> searchResults {get;set;} public List<QResult> QResultList{get; set;} public string BillingStreet { get { if (BillingStreet == null) BillingStreet = ''; // prefill the search box for ease of use return BillingStreet; } set; } public string BillingCity { get { if (BillingCity == null) BillingCity = ''; // prefill the search box for ease of use return BillingCity ; } set; } public string BillingPostalCode { get { if (BillingPostalCode == null) BillingPostalCode = ''; // prefill the search box for ease of use return BillingPostalCode ; } set; } public string BillingState { get { if (BillingState == null) BillingState = ''; // prefill the search box for ease of use return BillingState; } set; } //Constructor public AccountSearchController(ApexPages.StandardController controller) { //initialize the stanrdard controller this.controller = controller; this.a = (Account)controller.getRecord(); system.debug('AccountRec: ' +a); s=[ SELECT Id,Name,BillingStreet,BillingCity,BillingState,BillingPostalCode FROM Account WHERE Id=:a.Id]; sid1=a.Id; BillingStreet =s.BillingStreet; BillingCity=s.BillingState; BillingPostalCode=s.BillingPostalCode; BillingCity=s.BillingCity; BillingState=s.BillingState; search(); } // fired when the search button is clicked public PageReference search() { if (searchResults == null) { searchResults = new List<Account>(); // init the list if it is null } else { searchResults.clear(); // clear out the current results if they exist } // Use Dynamic SOQL to find the account based on user input String qry = 'Select o.Id,o.Name,o.BillingStreet,o.BillingCity,o.BillingState,o.BillingPostalCode from account o Where BillingStreet LIKE \'%'+BillingStreet+'%\' AND BillingCity LIKE \'%'+BillingCity+'%\' AND BillingState LIKE \'%'+BillingState+'%\' AND BillingPostalCode LIKE \'%'+BillingPostalCode+'%\' AND Id!=\''+a.Id+'\' ORDER By o.Name'; sid1=a.id; System.currentPagereference().getParameters().put(sid1,'success'); searchResults = Database.query(qry); if(searchResults==null) ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'No Records Found')); return null; } public PageReference amerge() { return null; } public class QResult{ public account acc {get; set;} public string pid {get; set;} public Boolean selected {get; set;} //This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property. We also set the selected value to false public QResult(account a) { acc = a; pid=''; selected = false; } } }
//************** VF Page ***************************// <apex:page standardController="Account" extensions="AccountSearchController"> <style type="text/css"> body {background: #F3F3EC; padding-top: 15px} </style> <apex:form title="Merger" > <apex:pageBlock title="Accounts with same Billing Address" id="block" mode="detail"> <apex:pageMessages /> <apex:pageBlockSection title="Search by" columns="1" id="detail" collapsible="false"> <apex:outputpanel id="thePanel" style=""> <p> <apex:pageblockSectionItem id="id1" labelStyle="font-weight:600" > <apex:outputLabel style="font-weight:600;padding-left:0px;padding-right:80px"> Billing Street</apex:outputLabel> </apex:pageblockSectionItem> <apex:pageblockSectionItem > <apex:outputLabel style="font-weight:600;padding-left:35px;padding-right:120px"> Billing City </apex:outputLabel> </apex:pageblockSectionItem> <apex:pageblockSectionItem > <apex:outputLabel style="font-weight:600;padding-left:5px;padding-right:80px"> Billing Zip Code </apex:outputLabel> </apex:pageblockSectionItem> <apex:pageblockSectionItem > <apex:outputLabel style="font-weight:600;padding-left:20px;padding-right:50px"> Billing State </apex:outputLabel> </apex:pageblockSectionItem> </p> <apex:inputText style="padding-left:0px;padding-right:50px" id="bs" value="{!BillingStreet}" label="Billing Street"/> <apex:inputText style="padding-left:0px;padding-right:50px" id="bc" value="{!BillingCity}" label="Billing City "/> <apex:inputText style="padding-left:0px;padding-right:50px" id="bz" value="{!BillingPostalCode}" label="Billing Zipcode "/> <apex:inputText style="padding-left:0px;padding-right:50px" id="bst" value="{!BillingState}" label="Billing State "/> </apex:outputPanel> </apex:pageBlockSection> <apex:pageBlockSection > <apex:panelGroup style="align:left" > <apex:commandButton value="Search" action="{!search}" rerender="resultsBlock" status="status"/> </apex:panelGroup> </apex:pageBlockSection> <apex:actionStatus id="status" startText="Searching... please wait..."/> <apex:pageBlockSection id="resultsBlock" columns="1"> <apex:pageBlockTable value="{!SearchResults}" var="o" rendered="{!NOT(ISNULL(SearchResults))}"> <!-- <apex:column headerValue="Key Values"> {!o} </apex:column> <apex:column headerValue="Values"> {!ResultMap[o]} </apex:column> --> <apex:column headerValue="Name"> <apex:outputLink value="/{!o.Id}">{!o.Name}</apex:outputLink> </apex:column> <apex:column value="{!o.BillingStreet}"/> <apex:column value="{!o.BillingCity}"/> <apex:column value="{!o.BillingPostalCode}"/> <apex:column value="{!o.BillingState}"/> <apex:column > <apex:commandbutton action="/merge/accmergewizard.jsp?goNext&cid={!sid1}&cid={!o.Id}" value="Merge" id="Merge" rendered="true" > </apex:commandbutton> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>