function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Deepika TestDeepika Test 

Account Quote Query

Hi All,
I have a requirement to create objects for Quote__c object(In lookup relationship with Account object) after clicking on a custom button present on the Quote section related list of Account page .Then according to the no. of products choosen from two multi select picklists present on Account object and redirect to the same Account detail record page.Please find my below code:
VF page:
<apex:page standardController="Account" extensions="PCSReferToMetGAController">
 <apex:form >
 <apex:pageblock title="Refer To MetGA">
<apex:pageblockSection columns="1" >
 <apex:inputField value="{!Account.PCS_Personal_Line_Products__c}"/><br/>

 <!-- <apex:outputLabel >Personal Line Products:</apex:outputLabel>
                 <apex:selectList value="{!Selectedpersonal}" multiselect="true" size="3">
                    <apex:selectOptions value="{!SelectedPersonal}"/>
                     </apex:selectList> -->
  <apex:inputField value="{!Account.PCS_Commercial_Line_Products__c}"/>
 
</apex:pageblockSection>
 <apex:pageBlockButtons >
 <apex:commandButton action="{!save}" value="Save"/>

 </apex:pageBlockButtons>
 
 
 </apex:pageblock>
 
 </apex:form>
</apex:page>
Apex Controller class:
public with sharing class PCSReferToMetGAController
{
public Account acc{get;set;}
public Apexpages.StandardController accController;
public String selectedPersonal{get;set;}
public String selectedCommercial{get;set;}
String aid{get;set;}

list<quote__c> qcList =new list<quote__c>();

list<quote__c> qpList =new list<quote__c>();
  
    public PCSReferToMetGAController(ApexPages.StandardController controller) 
    {
       this.accController=controller;
       acc=(Account)accController.getRecord();
        System.debug('Account Id ****'+acc.Id);
    }
    
     public void savePersonal()
    {
    system.debug('******Starting elements are:');
    selectedPersonal=acc.PCS_Personal_Line_Products__c;
    String[] s1;
    s1=selectedPersonal.split(';');
        List<String> plist=new List<String>();
    for(String s:s1)
    {
    plist.add(s);
    }
     system.debug('******pList elements are:'+pList);
    for(String i:pList)
    {
    Quote__c q1=new Quote__c();
    q1.PCS_Product_Line__c='Personal';
    q1.PCS_Product__c=i;
    q1.Account__c=acc.id;
    qpList.add(q1);
    }
    insert qpList;
    }
    public void saveCommercial()
    {
     selectedCommercial=acc.PCS_Commercial_Line_Products__c;
    String[] s2;
    s2=selectedCommercial.split(';');
    List<String> cList=new List<String>();
    for(String c:s2)
    {
    cList.add(c);
    }
     for(String i:cList)
    {
    Quote__c q1=new Quote__c();
    q1.PCS_Product_Line__c='Commercial';
    q1.PCS_Product__c=i;
    q1.Account__c=acc.id;
    qcList.add(q1);
    }
    insert qclist;
    }

    
    public pagereference save()
    {
    
    PCSReferToMetGAController p1=new PCSReferToMetGAController();
    
        System.debug('Account Id ****'+acc.Id);
       
        PageReference pg = new PageReference('/'+acc.id);
        
        pg.setRedirect(true);
        
        return pg;
      
    }
    }

Please find the above and let me know how to call the two methods from the save() ? ..thanks