• Nagaraju Mogili
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 13
    Replies
User-added image

I have displayed the Account object records and Edit and Delete buttons on the Visualforce Page, can anyone please let me know how can i Edit and delete from the vf page.
I want to show the number of contacts of an Account in the vf page using Apex code and Vf page..
 
trigger InvoiceSum on Invoice_Items__c (after insert, after update)
    {
     Set<Id> InvIds = new Set<Id>();   
     for(Invoice_Items__c ii :trigger.new)
     { InvIds.add(ii.InvoiceFK__c); }

        List<Invoice__c> InvRecs = [Select id, Ammount__c from Invoice__c where id in : InvIds ];
       
       for(Invoice__c inv : InvRecs)
        {
          //inv.Ammount__c= [Select sum(Invoice_items__r.Amount__c) from Invoice_Items__c ];
           Decimal total=0;
        //   for (Invoice_items__c iit: inc.Invoice_items__c)
          inv.Ammount__c =inv.Invoice_items__r.Amount__c;
            update inv;
        }
     
    }
Invoice__c is parent object and Invoice_item__c is child, I have to sum the all line items amount and display on Invoice__c record. Please help.
Populate Contacts in picklist based on selected .
If i select a picklist of Accountname--> all names will be displayed.
Then if i select a name  "conatcts" of that names must be displayed in a new picklist .

    public with sharing class AccountController1 {
    public String selectedAccId{get;set;}
          
           public List<SelectOption> getAccountNames() {
                  List<SelectOption> accOptions= new List<SelectOption>();
                  accOptions.add( new SelectOption('','--Select--'));
                  for( Account acc : [select Id,name from Account ] ) {
                          accOptions.add( new SelectOption(acc.Id,acc.name)); /*SelectOption list takes two parameters one is value and other one is label .In this case account name as a label and Id is the value .*/
                  }
                 return accOptions;
           }
    }
   
   
   
   
    <apex:page controller="AccountController1">
              <apex:form >
                       <apex:pageBlock title="Account Name">
                               Account Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                   <apex:selectList value="{!selectedAccId}" size="1">
                                               <apex:selectOptions value="{!AccountNames}" />
                                   </apex:selectList>
                      </apex:pageBlock>
            </apex:form>
    </apex:page>




Hi i am able to display the records of account name picklist, But if i select a picklist name its related contacts records must be displayed in a new picklist