You need to sign in to do that
Don't have an account?
If Condition values or If Condition is failing
Hi,
In my below controller something is wrong it is always goind to NULL Pointer Refernce. Please suggest me if there is anything wrong.
public with sharing class Pagination {
//URL Passing Parameters.
String PageContractId = ApexPages.currentPage().getParameters().get('ContractId');
String PageAccountId = ApexPages.currentPage().getParameters().get('AccountId');
/* set controller */
private ApexPages.StandardSetController setCon;
public Asset GetAccount{get;set;}
public Asset GetContract{get;set;}
public pagination ()
{
GetAccount = new Asset(); //Get Account Id from Page
GetContract = new Asset(); //Get Contract Name from Page
}
if ( GetAccount.AccountId == NULL & GetContract.Name == NULL )
{
if ( PageAccountId <> NULL & PageContractId == NULL )
{
this.setCon = new ApexPages.StandardSetController( [SELECT Id, AccountId,Product2Id,SerialNumber,last_contract_number__c,Service_Start_Date_Min__c, Service_End_Date_Max__c,InstallDate,Bundle_Support__c FROM Asset WHERE AccountId = :PageAccountId Order by Service_End_Date_Max__c Desc Limit 1000] );
}
else if ( PageAccountId == NULL & PageContractId <> NULL )
{
Contract C;
C = [SELECT Name FROM Contract WHERE Id = :PageContractId Limit 1];
this.setCon = new ApexPages.StandardSetController( [SELECT Id, AccountId,Product2Id,SerialNumber,last_contract_number__c,Service_Start_Date_Min__c, Service_End_Date_Max__c,InstallDate,Bundle_Support__c FROM Asset WHERE last_contract_number__c = :C.Name Order by Service_End_Date_Max__c Desc Limit 1000] );
}
}
else if ( GetAccount.AccountId <> NULL && GetContract.Name == NULL )
{
this.setCon = new ApexPages.StandardSetController( [SELECT Id, AccountId,Product2Id,SerialNumber,last_contract_number__c,Service_Start_Date_Min__c, Service_End_Date_Max__c,InstallDate,Bundle_Support__c FROM Asset WHERE AccountId = :GetAccount.AccountId Order by Service_End_Date_Max__c Desc Limit 1000] );
}
else if ( GetContract.Name <> NULL && GetAccount.AccountId == NULL )
{
this.setCon = new ApexPages.StandardSetController( [SELECT Id, AccountId,Product2Id,SerialNumber,last_contract_number__c,Service_Start_Date_Min__c, Service_End_Date_Max__c,InstallDate,Bundle_Support__c FROM Asset WHERE last_contract_number__c = :GetContract.Name Order by Service_End_Date_Max__c Desc Limit 1000] );
}
else if ( GetAccount.AccountId <> NULL && GetContract.Name <> NULL )
{
this.setCon = new ApexPages.StandardSetController( [SELECT Id, AccountId,Product2Id,SerialNumber,last_contract_number__c,Service_Start_Date_Min__c, Service_End_Date_Max__c,InstallDate,Bundle_Support__c FROM Asset WHERE AccountId = :GetAccount.AccountId and last_contract_number__c = :GetContract.Name Order by Service_End_Date_Max__c Desc Limit 1000] );
}
else
this.setCon = new ApexPages.StandardSetController( [SELECT Id, AccountId,Product2Id,SerialNumber,last_contract_number__c,Service_Start_Date_Min__c, Service_End_Date_Max__c,InstallDate,Bundle_Support__c FROM Asset WHERE AccountId = '0013000000DULXG' Order by Service_End_Date_Max__c Desc Limit 1000] );
}
Thanks
Sudhir
All Answers