• Somnath Paul 3
  • NEWBIE
  • 44 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 10
    Replies
Hi, I am new to the salesforce deployments. Please let me know how to retrieve and take backup of all the salesforce components (i.e. Profiles,Objects, Custom Fields etc) to git repository.

Can we retrieve all by using Ant and take the backup to github.
Please let me know.

Regards
Paul
Hi,
I am trying to write a Test Class for a Queueable apex class but the code coverage is not reaching 100%.

Queueable class:
public class AddPrimaryContact implements Queueable{
    private Contact con;
	private string state;
    public AddPrimaryContact(Contact con,String state)
    {
        this.con=con;
        this.state = state;
    }
    public void execute(QueueableContext Context)
    {
        Contact cont = [select Id,LastName,AccountId from Contact where Id=: con.Id limit 1];
        List<Account> accntlist = [select Id,Name,BillingState from Account where BillingState=: state limit 200];
        List<Contact> Conlist = new List<Contact>();
        for(Account a: accntlist)
        {	
            Contact cclone = cont.clone(false,false,false,false);
            cclone.AccountId = a.Id;
            Conlist.add(cclone);
        }
        insert Conlist;
    }
}

Test Class:
@isTest(seeAllData=false)
private class AddPrimaryContactTest {

    @testSetup
    static void setup()
    {
        List<Account> testAcnlist = new List<Account>();
        for(Integer i=0;i<50;i++)
        {
            Account a = new Account(Name='Test'+i,BillingCity='NY');
            testAcnlist.add(a);
        }
        for(Integer i=0;i<50;i++)
        {
            Account a = new Account(Name='Test'+i,BillingCity='CA');
            testAcnlist.add(a);
        }
        insert testAcnlist;
       Contact cnt = new Contact(LastName='TestContact');
        insert cnt;
    }
    static testmethod void testenqueuebale()
    {
         Contact conobj = [Select Id,Name,LastName from Contact where LastName='TestContact'];
        AddPrimaryContact apc = new AddPrimaryContact(conobj,'CA');
        Test.startTest();
        system.enqueueJob(apc);
        Test.stopTest();
        //system.assertNotEquals(null, [select Id,(Select LastName from contacts) from Account where BillingCity='CA']);
    }
}

Test Execution:
Strike through lines are not covered. Appreciate your help !!

public class AddPrimaryContact implements Queueable{
    private Contact con;
    private string state;
    public AddPrimaryContact(Contact con,String state)
    {
        this.con=con;
        this.state = state;
    }
    public void execute(QueueableContext Context)
    {
        Contact cont = [select Id,LastName,AccountId from Contact where Id=: con.Id limit 1];
        List<Account> accntlist = [select Id,Name,BillingState from Account where BillingState=: state limit 200];
        List<Contact> Conlist = new List<Contact>();
        for(Account a: accntlist)
        {    
            Contact cclone = cont.clone(false,false,false,false);
            cclone.AccountId = a.Id;
            Conlist.add(cclone);

        }
        insert Conlist;
    }
}

Regards
Somnath
Hi,

Need help in writing Test Class for the below Apex Class which use AggregateResult.
Apex Code:
 
global class AccountProcessor {
    
    @future
    public static void countContacts(List<Id> AccntIds)
    {
        List<Account> list_of_Account = [select Id,sompaul__Number_of_Contacts__c from Account where Id IN: AccntIds];
        system.debug('List of accounts'+list_of_Account);
        List<Account> accountToBeUpdated = new List<Account>();
        Integer Contact_cnt=0;
        //Map<Id,Decimal> = new Map<Id,Decimal>();
        List<AggregateResult> agrRes = [select count(Id),Contact.Account.Id from Contact,Contact.Account where Contact.Account.Id IN : AccntIds group by Contact.Account.Id];
        system.debug('AggregateResult value:'+agrRes);
        
        for(AggregateResult ar: agrRes)
        {
            
            for(Account a:list_of_Account)
            {
                if(a.Id == ar.get('Id'))
                {
                    a.sompaul__Number_of_Contacts__c = (Decimal)ar.get('expr0');
                    accountToBeUpdated.add(a);
                }
            }
            system.debug('Account Data to be updtaed'+accountToBeUpdated);
            
        }
        if(!accountToBeUpdated.isEmpty())
        {
            update accountToBeUpdated;
        }
        
    }
}

Test Class for the above:
@IsTest
private class AccountProcessorTest {
    
    private static testMethod void testAccountProcessor()
    {
        List<Id> accntList = new List<Id>();
        accntList = createAccount();
        Test.startTest();
        AccountProcessor.countContacts(accntList);
        Test.stopTest();
    }
    private static List<Id> createAccount()
    {
        List<Id> accntList = new List<Id>();
        for(Integer i=0;i<10;i++)
        {
            Account a = new Account(Name='Test Account'+i);
            for(Integer j=0;j<5;j++)
            {
                Contact con = new Contact(LastName ='Test Contact'+j,AccountId=a.Id);
            }
            accntList.add(a.Id);
        }
        return accntList;
    }

}

Code Coverage: 50%. Below strike through codes do not fall under test coverage.

global class AccountProcessor {
    
    @future
    public static void countContacts(List<Id> AccntIds)
    {
        List<Account> list_of_Account = [select Id,sompaul__Number_of_Contacts__c from Account where Id IN: AccntIds];
        system.debug('List of accounts'+list_of_Account);
        List<Account> accountToBeUpdated = new List<Account>();
        Integer Contact_cnt=0;
        //Map<Id,Decimal> = new Map<Id,Decimal>();
        List<AggregateResult> agrRes = [select count(Id),Contact.Account.Id from Contact,Contact.Account where Contact.Account.Id IN : AccntIds group by Contact.Account.Id];
        system.debug('AggregateResult value:'+agrRes);
        
        for(AggregateResult ar: agrRes)
        {
            
            for(Account a:list_of_Account)
            {
                if(a.Id == ar.get('Id'))
                {
                    a.sompaul__Number_of_Contacts__c = (Decimal)ar.get('expr0');
                    accountToBeUpdated.add(a);
                }
            }

            system.debug('Account Data to be updtaed'+accountToBeUpdated);
            
        }
        if(!accountToBeUpdated.isEmpty())
        {
            update accountToBeUpdated;
        }
        
    }
}

Can somebody please help here.
Thanks in advance !!
Hi All,

Recently we are working on a POC on Social Customer Service where we implmented the functionality of creating a Case in salesforce from a Facebook post. This functionality is working fine and we have built this interface as per the standard guide provided by Slaesforce. But below is the new requirement that we need to fulfill along with the existing functionality.

If we tag any Social Account on our home page and write any comment , that should also create a case in salesforce.
Please help me out how to implement this new feature. Whether this is feasible or not. Any useful documents or links would be appreciated.

Please find attached the screenshots.
Thanks in advance.
Regards
Somnath
Hi All,

Just wanted to understand one concept of trigger. Suppose we are loading 1000 Account records in the batch of 200. Thers is a trigger written on the Accoount object on after insert event. Then how many times the trigger will fire and how should it behave.

Moreover, there in the handler class of the trigger webservice callout is written. Will there be any constraint on the governor limit of the call out in that case.

Thanks !!!

Regards
Somnath
Hi, 
The following apex visualforce page and the controller retrieves the response which is getting captured in the debug log but does not get displayed on the vf page.

Apex Controller
============
public class BankDetailsController {
    
    public Id accId {get;set;}
    public Account acc {get;set;}
    public String accname {get; set;}
    public String Response {get; set;}
    public AsyncSoapSforceComSchemasClassGetbankdet.getBankDetailsResponse_elementFuture resp;
    public Object startAsyncCall() 
    {
         Account acc =  [select Name from Account where Id =: ApexPages.currentPage().getParameters().get('id')];
        Continuation con = new Continuation(60);
        con.ContinuationMethod = 'processResponse';
        
        //string accname = 'GoGlobalStrategies';
        partnerSoapSforceCom.Soap myPartnerSoap = new partnerSoapSforceCom.Soap(); 
        partnerSoapSforceCom.LoginResult partnerLoginResult = myPartnerSoap.login('somnath.paul4@cognizant.com', '**********');
        soapSforceComSchemasClassGetbankdet.SessionHeader_element webserviceSessionHeader=new soapSforceComSchemasClassGetbankdet.SessionHeader_element();
        webserviceSessionHeader.sessionId = partnerLoginResult.sessionId;
       // soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount getBankdet=new soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount();
        //getBankdet.SessionHeader=webserviceSessionHeader;*/
         AsyncSoapSforceComSchemasClassGetbankdet.AsyncGetBankDetailsofAccount asyngetbnkdet = new AsyncSoapSforceComSchemasClassGetbankdet.AsyncGetBankDetailsofAccount();
        
        asyngetbnkdet.SessionHeader = webserviceSessionHeader;
        system.debug('session header'+ asyngetbnkdet.SessionHeader);
        resp = asyngetbnkdet.beginGetBankDetails(con, acc.Name);
        system.debug('resp from action'+ resp);
        return con;
    }
    public Object processResponse()
    {
        Response = resp.getValue();
        system.debug('Response from get Value'+ Response);
        return null;
    }
        
}

VF Page
========
<apex:page controller="BankDetailsController">
     <apex:form >
   <apex:pageBlock >
         <apex:pageBlockSection >
               Congratulations {!$User.FirstName}
             Following are the Bank Details:
                   <apex:commandButton value="Get Bank Details" action="{!startAsyncCall}" reRender="Response"/>
       </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
    <apex:outputText value ="{!Response}"/>
</apex:page>


Can any body please reply what went wrong in the VF page. 
Hi All,

Just wanted to understand the difference between when to use Continutaion Class and when to use @future  (callout = true) in case asynchronous invocation of WS.

In case of imported WSDL, can we call the sync stub class from a method using @future(callout == true) or we have to use asyncWSDLtoApex class passing the continuation object.

Can anyone please explain both the concepts with bit explanation.

Great Thanks
Somnath
Hi,
I am trying to write a Test Class for a Queueable apex class but the code coverage is not reaching 100%.

Queueable class:
public class AddPrimaryContact implements Queueable{
    private Contact con;
	private string state;
    public AddPrimaryContact(Contact con,String state)
    {
        this.con=con;
        this.state = state;
    }
    public void execute(QueueableContext Context)
    {
        Contact cont = [select Id,LastName,AccountId from Contact where Id=: con.Id limit 1];
        List<Account> accntlist = [select Id,Name,BillingState from Account where BillingState=: state limit 200];
        List<Contact> Conlist = new List<Contact>();
        for(Account a: accntlist)
        {	
            Contact cclone = cont.clone(false,false,false,false);
            cclone.AccountId = a.Id;
            Conlist.add(cclone);
        }
        insert Conlist;
    }
}

Test Class:
@isTest(seeAllData=false)
private class AddPrimaryContactTest {

    @testSetup
    static void setup()
    {
        List<Account> testAcnlist = new List<Account>();
        for(Integer i=0;i<50;i++)
        {
            Account a = new Account(Name='Test'+i,BillingCity='NY');
            testAcnlist.add(a);
        }
        for(Integer i=0;i<50;i++)
        {
            Account a = new Account(Name='Test'+i,BillingCity='CA');
            testAcnlist.add(a);
        }
        insert testAcnlist;
       Contact cnt = new Contact(LastName='TestContact');
        insert cnt;
    }
    static testmethod void testenqueuebale()
    {
         Contact conobj = [Select Id,Name,LastName from Contact where LastName='TestContact'];
        AddPrimaryContact apc = new AddPrimaryContact(conobj,'CA');
        Test.startTest();
        system.enqueueJob(apc);
        Test.stopTest();
        //system.assertNotEquals(null, [select Id,(Select LastName from contacts) from Account where BillingCity='CA']);
    }
}

Test Execution:
Strike through lines are not covered. Appreciate your help !!

public class AddPrimaryContact implements Queueable{
    private Contact con;
    private string state;
    public AddPrimaryContact(Contact con,String state)
    {
        this.con=con;
        this.state = state;
    }
    public void execute(QueueableContext Context)
    {
        Contact cont = [select Id,LastName,AccountId from Contact where Id=: con.Id limit 1];
        List<Account> accntlist = [select Id,Name,BillingState from Account where BillingState=: state limit 200];
        List<Contact> Conlist = new List<Contact>();
        for(Account a: accntlist)
        {    
            Contact cclone = cont.clone(false,false,false,false);
            cclone.AccountId = a.Id;
            Conlist.add(cclone);

        }
        insert Conlist;
    }
}

Regards
Somnath
Hi,

Need help in writing Test Class for the below Apex Class which use AggregateResult.
Apex Code:
 
global class AccountProcessor {
    
    @future
    public static void countContacts(List<Id> AccntIds)
    {
        List<Account> list_of_Account = [select Id,sompaul__Number_of_Contacts__c from Account where Id IN: AccntIds];
        system.debug('List of accounts'+list_of_Account);
        List<Account> accountToBeUpdated = new List<Account>();
        Integer Contact_cnt=0;
        //Map<Id,Decimal> = new Map<Id,Decimal>();
        List<AggregateResult> agrRes = [select count(Id),Contact.Account.Id from Contact,Contact.Account where Contact.Account.Id IN : AccntIds group by Contact.Account.Id];
        system.debug('AggregateResult value:'+agrRes);
        
        for(AggregateResult ar: agrRes)
        {
            
            for(Account a:list_of_Account)
            {
                if(a.Id == ar.get('Id'))
                {
                    a.sompaul__Number_of_Contacts__c = (Decimal)ar.get('expr0');
                    accountToBeUpdated.add(a);
                }
            }
            system.debug('Account Data to be updtaed'+accountToBeUpdated);
            
        }
        if(!accountToBeUpdated.isEmpty())
        {
            update accountToBeUpdated;
        }
        
    }
}

Test Class for the above:
@IsTest
private class AccountProcessorTest {
    
    private static testMethod void testAccountProcessor()
    {
        List<Id> accntList = new List<Id>();
        accntList = createAccount();
        Test.startTest();
        AccountProcessor.countContacts(accntList);
        Test.stopTest();
    }
    private static List<Id> createAccount()
    {
        List<Id> accntList = new List<Id>();
        for(Integer i=0;i<10;i++)
        {
            Account a = new Account(Name='Test Account'+i);
            for(Integer j=0;j<5;j++)
            {
                Contact con = new Contact(LastName ='Test Contact'+j,AccountId=a.Id);
            }
            accntList.add(a.Id);
        }
        return accntList;
    }

}

Code Coverage: 50%. Below strike through codes do not fall under test coverage.

global class AccountProcessor {
    
    @future
    public static void countContacts(List<Id> AccntIds)
    {
        List<Account> list_of_Account = [select Id,sompaul__Number_of_Contacts__c from Account where Id IN: AccntIds];
        system.debug('List of accounts'+list_of_Account);
        List<Account> accountToBeUpdated = new List<Account>();
        Integer Contact_cnt=0;
        //Map<Id,Decimal> = new Map<Id,Decimal>();
        List<AggregateResult> agrRes = [select count(Id),Contact.Account.Id from Contact,Contact.Account where Contact.Account.Id IN : AccntIds group by Contact.Account.Id];
        system.debug('AggregateResult value:'+agrRes);
        
        for(AggregateResult ar: agrRes)
        {
            
            for(Account a:list_of_Account)
            {
                if(a.Id == ar.get('Id'))
                {
                    a.sompaul__Number_of_Contacts__c = (Decimal)ar.get('expr0');
                    accountToBeUpdated.add(a);
                }
            }

            system.debug('Account Data to be updtaed'+accountToBeUpdated);
            
        }
        if(!accountToBeUpdated.isEmpty())
        {
            update accountToBeUpdated;
        }
        
    }
}

Can somebody please help here.
Thanks in advance !!
How do I change the email address to log into Salesforce? 
Hi All,

Recently we are working on a POC on Social Customer Service where we implmented the functionality of creating a Case in salesforce from a Facebook post. This functionality is working fine and we have built this interface as per the standard guide provided by Slaesforce. But below is the new requirement that we need to fulfill along with the existing functionality.

If we tag any Social Account on our home page and write any comment , that should also create a case in salesforce.
Please help me out how to implement this new feature. Whether this is feasible or not. Any useful documents or links would be appreciated.

Please find attached the screenshots.
Thanks in advance.
Regards
Somnath
Hi, 
The following apex visualforce page and the controller retrieves the response which is getting captured in the debug log but does not get displayed on the vf page.

Apex Controller
============
public class BankDetailsController {
    
    public Id accId {get;set;}
    public Account acc {get;set;}
    public String accname {get; set;}
    public String Response {get; set;}
    public AsyncSoapSforceComSchemasClassGetbankdet.getBankDetailsResponse_elementFuture resp;
    public Object startAsyncCall() 
    {
         Account acc =  [select Name from Account where Id =: ApexPages.currentPage().getParameters().get('id')];
        Continuation con = new Continuation(60);
        con.ContinuationMethod = 'processResponse';
        
        //string accname = 'GoGlobalStrategies';
        partnerSoapSforceCom.Soap myPartnerSoap = new partnerSoapSforceCom.Soap(); 
        partnerSoapSforceCom.LoginResult partnerLoginResult = myPartnerSoap.login('somnath.paul4@cognizant.com', '**********');
        soapSforceComSchemasClassGetbankdet.SessionHeader_element webserviceSessionHeader=new soapSforceComSchemasClassGetbankdet.SessionHeader_element();
        webserviceSessionHeader.sessionId = partnerLoginResult.sessionId;
       // soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount getBankdet=new soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount();
        //getBankdet.SessionHeader=webserviceSessionHeader;*/
         AsyncSoapSforceComSchemasClassGetbankdet.AsyncGetBankDetailsofAccount asyngetbnkdet = new AsyncSoapSforceComSchemasClassGetbankdet.AsyncGetBankDetailsofAccount();
        
        asyngetbnkdet.SessionHeader = webserviceSessionHeader;
        system.debug('session header'+ asyngetbnkdet.SessionHeader);
        resp = asyngetbnkdet.beginGetBankDetails(con, acc.Name);
        system.debug('resp from action'+ resp);
        return con;
    }
    public Object processResponse()
    {
        Response = resp.getValue();
        system.debug('Response from get Value'+ Response);
        return null;
    }
        
}

VF Page
========
<apex:page controller="BankDetailsController">
     <apex:form >
   <apex:pageBlock >
         <apex:pageBlockSection >
               Congratulations {!$User.FirstName}
             Following are the Bank Details:
                   <apex:commandButton value="Get Bank Details" action="{!startAsyncCall}" reRender="Response"/>
       </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
    <apex:outputText value ="{!Response}"/>
</apex:page>


Can any body please reply what went wrong in the VF page. 
Hi All,

Just wanted to understand the difference between when to use Continutaion Class and when to use @future  (callout = true) in case asynchronous invocation of WS.

In case of imported WSDL, can we call the sync stub class from a method using @future(callout == true) or we have to use asyncWSDLtoApex class passing the continuation object.

Can anyone please explain both the concepts with bit explanation.

Great Thanks
Somnath
 public class soapSforceComSchemasClassAccountins {
 public class SessionHeader_element {
        public String x00D90000000y0lh_AQ0AQGIsi542TCnp_73StsP8nawV5_7uVrHfVM0SyclcA_h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ;
        private String[] x00D90000000y0lh_AQ0AQGIsi542TCnp_73StsP8nawV5_7uVrHfVM0SyclcA_h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ_type_info = new String[]{'00D90000000y0lh!AQ0AQGIsi542TCnp.73StsP8nawV5.7uVrHfVM0SyclcA.h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ','http://soap.sforce.com/schemas/class/AccountInsert',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/AccountInsert','true','false'};
        private String[] field_order_type_info = new String[]{'x00D90000000y0lh_AQ0AQGIsi542TCnp_73StsP8nawV5_7uVrHfVM0SyclcA_h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ'};
    }
    public class DebuggingInfo_element {
        public String debugLog;
        private String[] debugLog_type_info = new String[]{'debugLog','http://soap.sforce.com/schemas/class/AccountInsert',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/AccountInsert','true','false'};
        private String[] field_order_type_info = new String[]{'debugLog'};
    }
    public class AccountInsert {
        public String endpoint_x = 'https://ap1.salesforce.com/services/Soap/class/AccountInsert';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        public soapSforceComSchemasClassAccountins.SessionHeader_element SessionHeader;
        public soapSforceComSchemasClassAccountins.DebuggingInfo_element DebuggingInfo;
        public soapSforceComSchemasClassAccountins.CallOptions_element CallOptions;
        public soapSforceComSchemasClassAccountins.DebuggingHeader_element DebuggingHeader;
        public soapSforceComSchemasClassAccountins.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
        private String SessionHeader_hns = 'SessionHeader=http://soap.sforce.com/schemas/class/AccountInsert';
        private String DebuggingInfo_hns = 'DebuggingInfo=http://soap.sforce.com/schemas/class/AccountInsert';
        private String CallOptions_hns = 'CallOptions=http://soap.sforce.com/schemas/class/AccountInsert';
        private String DebuggingHeader_hns = 'DebuggingHeader=http://soap.sforce.com/schemas/class/AccountInsert';
        private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=http://soap.sforce.com/schemas/class/AccountInsert';
        private String[] ns_map_type_info = new String[]{'http://soap.sforce.com/schemas/class/AccountInsert', 'soapSforceComSchemasClassAccountins'};
        public void opportunityUpdate(String Name,String AccountNumber,String Description) {
            soapSforceComSchemasClassAccountins.opportunityUpdate_element request_x = new soapSforceComSchemasClassAccountins.opportunityUpdate_element();
            request_x.Name = Name;
            request_x.AccountNumber = AccountNumber;
            request_x.Description = Description;
            soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element response_x;
            Map<String, soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element> response_map_x = new Map<String, soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://soap.sforce.com/schemas/class/AccountInsert',
              'opportunityUpdate',
              'http://soap.sforce.com/schemas/class/AccountInsert',
              'opportunityUpdateResponse',
              'soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element'}
            );
            response_x = response_map_x.get('response_x');
        }
}

}
executing through Developer Console from other Salesforce Org:::

soapSforceComSchemasClassAccountins.AccountInsert a = new soapSforceComSchemasClassAccountins.AccountInsert();
a.opportunityUpdate('Microsoft','21232','Cognizant');

Line: 111, Column: 1
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: 

INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor=
Hello All,

 I am trying to pass the Input field value from Visualforce page to apex controller class.
 Please let me know how to capture the value.

 Below is the code.

<apex:page standardController="Activity_Tracker__c" extensions="dependentPicklistController"> 
  <apex:messages style="color:red"></apex:messages>
    <apex:form >
        <apex:pageblock >
            <apex:pageblockSection >
               <apex:inputField value="{!Activity_Tracker__c.Category__c}" />
               <apex:inputField value="{!Activity_Tracker__c.Sub_Customers__c}" />
            </apex:pageblockSection>
        </apex:pageblock>
        

         <apex:commandButton action="{!search}" value="search"/>
         <apex:pageBlock >
         <apex:pageBlockTable value="{!records}" var="item">
                <apex:column value="{!item.Category__c}"/>
                <apex:column value="{!item.Sub_Customers__c}"/>
                <apex:column value="{!item.Status__c }"/>
           </apex:pageBlockTable>
         </apex:pageBlock>
    </apex:form>
</apex:page>


Controller --
public with sharing class dependentPicklistController{
    public List<Activity_Tracker__c> records{get;set;}
    public Activity_Tracker__c  Category__c{get; set;}
 
    public pagereference search()
    {
       records=[Select ID, Category__c, Sub_Customers__c, Status__c From Activity_Tracker__c   ];
       system.debug('11111' +Query);
       return null;
    }
}

In this I am trying to capture Category__c, Sub_Customers__c (Dependent Picklists) in the Apex Class.

Thanks...