• kumar 197
  • NEWBIE
  • 20 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
<apex:page controller="FlightController">
    <apex:pageBlock title="Select Flights">
      <apex:form >
        <apex:pageBlockSection >
       <apex:pageBlockSectionItem >
       <apex:outputText value="Flights"/>
        <apex:selectList size="1" value="{! fosId }">
        <apex:selectOptions value="{! fosList }"/>
        <apex:actionSupport event="onchange" reRender="FL01"/>
         </apex:selectList>
        </apex:pageBlockSectionItem>
         </apex:pageBlockSection>
         </apex:form>   
         </apex:pageBlock>
          <apex:pageBlock id="FL01">
        <apex:detail subject="{!fosId}" relatedlist="True"/>
       <apex:relatedList list="Booking__c"/>      
    </apex:pageBlock>
</apex:page>
--------------------------------------------
public class FlightController {

    public List<SelectOption> flights = new List<SelectOption>();
    public Id fosId {get;set;}
    
    public List<SelectOption> getfosList(){
        for(Flight__c fos : [SELECT Id, Name,(SELECT Name,Id FROM Bookings__r  ORDER BY BoardingDate__c DESC) FROM Flight__c]){
            flights.add(new SelectOption(fos.Id, fos.Name));
        }
        return flights;
    }
}
trigger ContactCount on Contact (after insert, after update, after delete, after undelete) {
    
    if(Trigger.isinsert || Trigger.isupdate || trigger.isdelete || Trigger.isundelete){
       
        ContactCount.countcontacts(trigger.new,trigger.old);
        
    }
}

-----------
public class ContactCount {
    public static void countcontacts(List<contact> newcontact,List<contact> oldcontact){
     
        set<id> accids= new set<id>();
                try{
        if(newcontact !=null){
            for(Contact c:newcontact){
                if(c.AccountId!=null){
                accids.add(c.accountid);
                }
            }      
       }if(oldcontact!=null){
            for(Contact c:oldcontact){
                accids.add(c.accountid);
            }
       }
     List<Account> acc = [Select id, Number_of_Contacts__c,(Select id from Contacts) from Account where id IN: accids];
        if(acc!=null){
        for(Account accValue:acc){
            accValue.Number_of_Contacts__c = accValue.Contacts.size();
        } 
        }
        if(!acc.isempty()){
        update acc;
        }
        }
        catch(exception e){
            System.debug('Get Message'+e.getMessage());
        }
    } 
}
Starting SFDX: Authorize an Org
15:23:42.658 sfdx force:auth:web:login --setalias vscodeOrg --instanceurl https://login.salesforce.com --setdefaultusername
Node.js is only supported on Windows 8.1, Windows Server 2012 R2, or higher.
Setting the NODE_SKIP_PLATFORM_CHECK environment variable to 1 skips this
check, but Node.js might not execute correctly. Any issues encountered on
unsupported platforms will not be fixed.15:23:42.729 sfdx force:auth:web:login --setalias vscodeOrg --instanceurl https://login.salesforce.com --setdefaultusername
 ended with exit code 216

i have even downloaded node.js v12
<apex:page controller="FlightController">
    <apex:pageBlock title="Select Flights">
      <apex:form >
        <apex:pageBlockSection >
       <apex:pageBlockSectionItem >
       <apex:outputText value="Flights"/>
        <apex:selectList size="1" value="{! fosId }">
        <apex:selectOptions value="{! fosList }"/>
        <apex:actionSupport event="onchange" reRender="FL01"/>
         </apex:selectList>
        </apex:pageBlockSectionItem>
         </apex:pageBlockSection>
         </apex:form>   
         </apex:pageBlock>
          <apex:pageBlock id="FL01">
        <apex:detail subject="{!fosId}" relatedlist="True"/>
       <apex:relatedList list="Booking__c"/>      
    </apex:pageBlock>
</apex:page>
--------------------------------------------
public class FlightController {

    public List<SelectOption> flights = new List<SelectOption>();
    public Id fosId {get;set;}
    
    public List<SelectOption> getfosList(){
        for(Flight__c fos : [SELECT Id, Name,(SELECT Name,Id FROM Bookings__r  ORDER BY BoardingDate__c DESC) FROM Flight__c]){
            flights.add(new SelectOption(fos.Id, fos.Name));
        }
        return flights;
    }
}