-5

Objects: Account(Parent lookup of) Billing_change_Form__c (Parent Lookup of) Contingency__c

Fields: On Billing_Change_Form__c [account__c (id of account), case_findings__c (Long text field) on contingency__c(name)]

Requirements: I am building a custom button on a field (Case Finding) on Billing_Change_Form__c that will pop-up a VF page. VF page should display all the records from contingency that are associated with the account on Billing_Change_Form__c. I should been able to select and add multiple records to the field(Case finding)

Questions: 1) How do I access records from contingency__c that are associated with the account on bill_changing_form__c?

2) How do I attach those records in the case findings field from the VF page? After hitting the insert button on the pop-up VF page.

Controller:

public with sharing class customMutliSelectLookUpCntrl {

    //Declare Variable
    public List<Contingency__c> caseFindings {get;set;}
    public String searchString {get;set;}
    public string caseId; 
    public List<Billing_Change_Form__c> bills {get;set;}
    private final Billing_Change_form__c bcf{get;set;}
    public boolean isChecked{get;set;}
    public string namePassToText {get;set;}
    public string nameToHdn {get;set;}

    //Page Reference
    ApexPages.StandardController bcfCtrl;

    //Constructor 
    public customMutliSelectLookUpCntrl(ApexPages.StandardController controller)
    {   
        this.bcf = (Billing_Change_Form__c)controller.getRecord();
        bcfCtrl = controller;
       string caseId = ApexPages.currentPage().getParameters().get('id'); 
        caseFindings = [select id, name, billing_type__c, report_description__c, discovery_amount__c,
                        billing_begins_date__c,  contingency__c from contingency__c
                       WHERE Id = :caseId AND contingency__c like 'IN BILLING'];

        string billId = ApexPages.currentPage().getParameters().get('id');
        bills = [select id, account__c, billing_status__c, Case_finding__c, status__c, reason_what_why__c
                from billing_change_form__c
                WHERE Id = :billId];

        searchString='';

        doQuery();

    }


    //Method for searching 

    public void doQuery()
    {
        String queryString= '';
        if(searchString !=null) //add in % in the query string
            queryString = '%' +searchString+ '%';

        caseFindings = [select id, name, billing_type__c, report_description__c, discovery_amount__c,
                        billing_begins_date__c, contingency__c from contingency__c ca
                       where name like :queryString]; //Add criteria to search by
    }

    //Saving Records after updating 
    public void save(){
        update caseFindings;
    }
    // Getting fields based on Account
            public list<contingency__c> getCaseofAcc(){
        list<contingency__c> acc = new list<contingency__c>();
        list<billing_change_form__c> accID = [select account__c,Account__r.id from billing_change_form__c
                                             where account__c = Account__r.id];

    //Event for check box is checked

    //Inserting the records after checking
        public void toInsert(){

}
}

VF Page:

<apex:page showHeader="False" standardController="Billing_Change_Form__c" extensions="customMutliSelectLookUpCntrl" >

    <!-- Page Styling -->
    <style type="text/css">

.customPopupStyle{ background-color: white; border-style: solid; border-width: 2px; left:20%; padding:10px; position: absolute; z-index: 9999; width: 500px; top:20%;} 
        .disabledTextBoxStyle{ background-color: white; border: 1px solid; color: black; cursor: default; width: 90px; display: table; padding: 2px 1px; text-align: right;}
        .closeButtonStyle{ float: right;}

</style>
   <apex:form id="mainFormId">

       <apex:pageBlock title="Case Findings" id="myData">

         <!-- actionFunction is for calling the controller method -->
        <apex:actionFunction action="{!doQuery}" name="apexDoQuery" reRender="myData"/>


        <!-- Filter Section -->
       <div class="filterDiv">
           <label> Filer By Name</label>
           <apex:inputText value="{!searchString}" onkeyup="apexDoQuery()"/>
        </div> 
       <!-- My Page Block -->


        <apex:pageBlockButtons >
                <apex:commandButton value="Insert" />
                <apex:commandButton value="Close" onclick="window.top.close();" immediate="true"/>
            </apex:pageBlockButtons>

        <apex:pageBlockTable value="{!caseFindings}" var="c">

            <apex:column >
                <apex:inputCheckbox />
            </apex:column>
            <apex:column value="{!c.name}"/>

            <apex:column value="{!c.BILLING_TYPE__c}"/>

            <apex:column value="{!c.DISCOVERY_AMOUNT__c}"/>            

            <apex:column value="{!c.BILLING_BEGINS_DATE__c}"/>


            <apex:column value="{!c.REPORT_DESCRIPTION__c}"/>

            <apex:column value="{!c.CONTINGENCY__c}"/>

        </apex:pageBlockTable>>
    </apex:pageBlock>
    </apex:form>
</apex:page>

I am very new to this field. This is my first VF page and Apex class. Any help will be appreciated! Thank you

closed as too broad by battery.cord, David Reed, codeyinthecloud, Jayant Das, Reshma Jan 12 at 7:07

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.