You need to sign in to do that
Don't have an account?
SFDC Dummy
How to search record datewise...
Hi...
I have created a page which will search record date wise...
like i have record
date value
10/9/2015--------------------a
11/9/2015--------------------aa
12/9/2015--------------------aaa
14/9/2015--------------------aaaa
15/9/2015--------------------aaaaa
20/9/2015--------------------aaaaaa
if i am searching record on 10/9/2015 the record will be display 'a'
if i am searching record on 11/9/2015 the record will be display 'aa'
if i am searching record on 13/9/2015 the record will be display 'aa'(12/9/2015 record)
if i am searching record on 14/9/2015 the record will be display 'aaaa'
if i am searching record on 20/9/2015 the record will be display 'aaaaaa'
if i am searching record on 19/9/2015 the record will be display 'aaaaa'(15/9/2015 record)
if there is record on particular date it will display if there is no record on that date it will display last date record
I have created a page which will search record date wise...
like i have record
date value
10/9/2015--------------------a
11/9/2015--------------------aa
12/9/2015--------------------aaa
14/9/2015--------------------aaaa
15/9/2015--------------------aaaaa
20/9/2015--------------------aaaaaa
if i am searching record on 10/9/2015 the record will be display 'a'
if i am searching record on 11/9/2015 the record will be display 'aa'
if i am searching record on 13/9/2015 the record will be display 'aa'(12/9/2015 record)
if i am searching record on 14/9/2015 the record will be display 'aaaa'
if i am searching record on 20/9/2015 the record will be display 'aaaaaa'
if i am searching record on 19/9/2015 the record will be display 'aaaaa'(15/9/2015 record)
if there is record on particular date it will display if there is no record on that date it will display last date record
public with sharing class dateInPBTbaleController { public dateInPBTbaleController() { } public dateInPBTbaleController(ApexPages.StandardController controller) { account = new BankBook_Entry__c(); totalRevenue = 0; totalRevenue1 = 0; totalRevenuee = 0; } public BankBook_Entry__c account{get;set;} public List<BankBook_Entry__c> listAccount {get;set;} public Date startDate1; public Date endDat1; public Double totalRevenue {get;set;} public Double totalRevenue1 {get;set;} public Double totalRevenuee {get;set;} public Double totalRevenuee1 {get;set;} public Date dat {get;set;} // public dateInPBTbaleController() { public void displaingTable(){ startDate1 = account.Date__c; endDat1 = account.Date__c; if(endDat1!=null){ listAccount = [SELECT id, CB__c,Date__c,Debit__c,Master_Code1__c,Master_Name__c,Bank_Closing_Balance__c FROM BankBook_Entry__c WHERE Date__c>=:startDate1 AND Date__c<=:endDat1 order by Master_Code1__c ASC ]; }//Date__c>=:startDate1 AND calculateTotalRevenue(); calculateTotalRevenue1(); calculateTotalRevenue2(); } public void calculateTotalRevenue() { for(BankBook_Entry__c acct : listAccount) { if(acct.Debit__c!= null) totalRevenue+= acct.Debit__c; } } public void calculateTotalRevenue2() { for(BankBook_Entry__c acct2 : listAccount) { if(acct2.Bank_Closing_Balance__c!= null) totalRevenuee= acct2.Bank_Closing_Balance__c; // totalRevenuee+= acct.Bank_Closing_Balance__c+totalRevenue; } } public void calculateTotalRevenue1() { for(BankBook_Entry__c acct1 : listAccount) { if(acct1.CB__c!= null) totalRevenue1+= acct1.CB__c; } } } ---------------------------------------------------------------------- <apex:page docType="html-5.0" standardController="BankBook_Entry__c" extensions="dateInPBTbaleController"> <apex:define name="body"> <div style="width:800px;margin: 0px auto 10px auto;border: 1px solid black;"> <apex:form > <apex:pageBlock > <b><apex:outputLabel value="Trial Balance Report On: " style="font-weight: bold;color:red;"/></b> <apex:inputField value="{!account.Date__c}" style="font-weight: bold;color:red;"/> <!--- Trial Balance Report On: <apex:input type="date" value="{!dat}"/>--> <apex:commandButton value="Display" action="{!displaingTable}" reRender="tableId" style="font-weight: bold;color:red;"/><br/><br/><br/> <apex:pageblockTable value="{!listAccount }" var="record" id="tableId" > <apex:column value="{!record.Master_Code1__c}" headerValue="Master Code"/> <apex:column value="{!record.Master_Name__c}" headerValue="Master Name"/> <apex:column value="{!record.Debit__c}" headerValue="Debit(+)" style="color:green;" id="tableId"> <apex:facet name="footer" > <apex:outputText value="Rs.{0, number, ###,###,###,##0.00}" style="font-weight: bold;color:green;font-size:12px;height=18px;" > <apex:param value="{!totalRevenue}" /> </apex:outputText> </apex:facet> </apex:column> <apex:column value="{!record.CB__c}" headerValue="Credit(-)" style="color:red;"> <apex:facet name="footer" > <apex:outputText value="Rs.{0, number, ###,###,###,##0.00}" style="font-weight: bold;color:red;font-size:12px;height=18px;" > <apex:param value="{!totalRevenue1}" /> </apex:outputText> </apex:facet> </apex:column> <apex:column value="{!record.Bank_Closing_Balance__c}" headerValue="Bank Closing Balance" style="color:green;"> <apex:facet name="footer" > <apex:outputText value="Rs.{0, number, ###,###,###,##0.00}" style="font-weight: bold;color:red;font-size:12px;height=18px;" > <apex:param value="{!totalRevenue1}" /> </apex:outputText> </apex:facet> </apex:column> </apex:pageblockTable> </apex:pageBlock> </apex:form> </div> </apex:define> </apex:page>
All Answers
Please add below mention code in your Vf page and Controller class :
VF Page code :
<apex:inputField value="{searchDateField}"/>
<apex:commandButton value="Search" action="{!search} rerender="datePanel"/>"
<apex:outputPanel id="datePanel" rendered="{!If(resultantDate != null, true,false)}">
<apex:outputLabel value="Resultant Date :"/>
<apex:outputField value="{!resultantDate}"/>
</apex:outputPanel>
Class Code :
public Date searchDateField {get;set;}
public Date resultantDate {get;set;}
public void Search(){
List<BankBook_Entry__c> acc = new List<BankBook_Entry__c>();
acc = [Select Date__c from BankBook_Entry__c where Date__c = :searchDateField LIMIT 1];
if(acc.size() == 0) {
acc = [Select Date__c from BankBook_Entry__c where Date__c < :searchDateField LIMIT 1];
}
if(acc.size() == 0) {
acc = [Select Date__c from BankBook_Entry__c Order By Date__c DESC LIMIT 1];
}
resultantDate = acc[0].Date__c;
}
Plesae let me know if you need any help regarding this.
Thanks,
Abhishek
I have modified your controller class according to your requirement.
Please ignore the previous post and update your class code as follows :
public with sharing class dateInPBTbaleController {
public BankBook_Entry__c account{get;set;}
public List<BankBook_Entry__c> listAccount {get;set;}
//public Date startDate1;
//public Date endDat1;
public Double totalRevenue {get;set;}
public Double totalRevenue1 {get;set;}
public Double totalRevenuee {get;set;}
public Double totalRevenuee1 {get;set;}
public Date dat {get;set;}
public dateInPBTbaleController() {
listAccount = [SELECT id, CB__c,Date__c,Debit__c,Master_Code1__c,Master_Name__c,Bank_Closing_Balance__c
FROM BankBook_Entry__c
order by Master_Code1__c ASC ];
}
public dateInPBTbaleController(ApexPages.StandardController controller){
account = new BankBook_Entry__c();
totalRevenue = 0;
totalRevenue1 = 0;
totalRevenuee = 0;
}
public void displaingTable(){
if(account.Date__c != null){
listAccount = [SELECT id, CB__c,Date__c,Debit__c,Master_Code1__c,Master_Name__c,Bank_Closing_Balance__c
FROM BankBook_Entry__c
WHERE Date__c =: account.Date__c order by Master_Code1__c ASC ];
if(listAccount.size() == 0){
listAccount = [SELECT id, CB__c,Date__c,Debit__c,Master_Code1__c,Master_Name__c,Bank_Closing_Balance__c
FROM BankBook_Entry__c
WHERE Date__c <: account.Date__c order by Master_Code1__c ASC ];
}
if(listAccount.size() == 0){
listAccount = [SELECT id, CB__c,Date__c,Debit__c,Master_Code1__c,Master_Name__c,Bank_Closing_Balance__c
FROM BankBook_Entry__c
order by Date__c DESC LIMIT 1 ];
}
}
calculateTotalRevenue();
calculateTotalRevenue1();
calculateTotalRevenue2();
}
public void calculateTotalRevenue() {
for(BankBook_Entry__c acct : listAccount) {
if(acct.Debit__c!= null)
totalRevenue+= acct.Debit__c;
}
}
public void calculateTotalRevenue2() {
for(BankBook_Entry__c acct2 : listAccount) {
if(acct2.Bank_Closing_Balance__c!= null)
totalRevenuee= acct2.Bank_Closing_Balance__c;
// totalRevenuee+= acct.Bank_Closing_Balance__c+totalRevenue;
}
}
public void calculateTotalRevenue1() {
for(BankBook_Entry__c acct1 : listAccount) {
if(acct1.CB__c!= null)
totalRevenue1+= acct1.CB__c;
}
}
}
Let me know if there is any issue.
Regards,
Abhishek.
Please modify this method code :
public void displaingTable(){
if(account.Date__c != null){
listAccount = [SELECT id, CB__c,Date__c,Debit__c,Master_Code1__c,Master_Name__c,Bank_Closing_Balance__c
FROM BankBook_Entry__c
WHERE Date__c =: account.Date__c order by Master_Code1__c ASC ];
if(listAccount.size() == 0){
listAccount = [SELECT id, CB__c,Date__c,Debit__c,Master_Code1__c,Master_Name__c,Bank_Closing_Balance__c
FROM BankBook_Entry__c
WHERE Date__c <: account.Date__c order by Master_Code1__c ASC LIMIT 1 ];
}
if(listAccount.size() == 0){
listAccount = [SELECT id, CB__c,Date__c,Debit__c,Master_Code1__c,Master_Name__c,Bank_Closing_Balance__c
FROM BankBook_Entry__c
order by Date__c DESC LIMIT 1 ];
}
}
Regards,
Abhishek
I have tried above modified code but it will dispaly only one record..i have 10/1/2001 record if i am searching 10/1/2001 it will dispaly like this
As per my requirment there is no record in 11/1/2001....If i am searching on that day it will be display last day record ,means 10/1/2001 record only.but it will dispaly
In order to achieve your requirement i have modified your code :
Please fin below the updated code :
Please let me know if any issue is there.
Regards,
Abhishek
List<BankBook_Entry__c> listOfEntryData;
[Error] Error: dateInPBTbaleController Compile Error: Variable does not exist: allDataList at line 18 column 39
public Map<Date,List<BankBook_Entry__c>> mapOfDateWithEntry = new Map<Date,List<BankBook_Entry__c>>();
Are you facing any issue with the code provided by me.
If Yes, please let me know the issue, I will definitely try to help you out.
Are you facing any issue with the code provided by me.
If Yes, please let me know the issue, I will definitely try to help you out.
I have provided you the code regarding your requirement.
Please change your controller class with below code :
Please execute the above code and let me know if you have any issue.
If this code does not work than please let me know which cases are working and which are not working.
I will modify the code accordingly.
Regards,
Abhishek
Please remove one dot.
Change mapOfDateWithEntry..put(entry.Date__c,listOfEntryData); To mapOfDateWithEntry.put(entry.Date__c,listOfEntryData);
I think you have updated the code.
Please send me the code of controller class.
Visualforce ErrorHelp for this Page
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!displaingTable}' in component <apex:commandButton> in page newtrial1: Class.dateInPBTbaleControllernew1.calculateTotalRevenue: line 82, column 1
Class.dateInPBTbaleControllernew1.displaingTable: line 75, column 1
Class.dateInPBTbaleControllernew1.calculateTotalRevenue: line 82, column 1
Class.dateInPBTbaleControllernew1.displaingTable: line 75, column 1
listAccount = new List<>([SELECT id, CB__c,Date__c,Debit__c,Master_Code1__c,Master_Name__c,Bank_Closing_Balance__c
FROM BankBook_Entry__c
order by Master_Code1__c ASC ]);
Please let me know if any issue is still there.
listAccount = new List<BankBook_Entry__c>([SELECT id, CB__c,Date__c,Debit__c,Master_Code1__c,Master_Name__c,Bank_Closing_Balance__c
FROM BankBook_Entry__c
order by Master_Code1__c ASC ]);
Let me know if you still face any issue.
Not able to find the root cause of this error.
If possible, Please share credential of your org so that i can look into it.
Regards,
Abhishek.
can u explain it again ?
see the screenshot
Please check and mark your both answer as SOLVED in order to avoid confusion.
Thanks,
Abhishek.
I have two custom object debtor and mastercopy.
In debtors object i have 10 record .when i am updating any record of debtors it will be created all 10 record in matsercopy automatically.if i am inserting any record on debtors it will be created all record i mean past 10 record and new inserted record in masetr copy..
if i am upadting any record with change of date it will created all record in mastercopy.
for exmplae
debtors object
1------a-----10000-------1/1/2001
2------aa-----20000-------2/1/2001
3------aaa-----20000-------3/1/2001
4------aaaa-----30000-------4/1/2001
5------aaaaa-----60000-------5/1/2001
mastercopy record
initially blank
when i am upadting one record like 1----- a-----10000-------1/1/2001 to 1------a-----90000-------10/1/2001 after saving the record in debtors it will be automatically created all record in mastercopy object with updated date in all record like
mastercopy object after update debtors object..
1------a-----90000-------10/1/2001
2------aa-----20000-------10/1/2001
3------aaa-----20000-------10/1/2001
4------aaaa-----30000-------10/1/2001
5------aaaaa-----60000-------10/1/2001
if i am updating any record with same date in debtors object like 2------aa-----20000-------10/1/2001 to 2------aa-----240000-------10/1/2001 it will update the mastercopy record..
1------a-----90000-------10/1/2001
2------aa-----240000-------10/1/2001
3------aaa-----20000-------10/1/2001
4------aaaa-----30000-------10/1/2001
5------aaaaa-----60000-------10/1/2001
if date same it will be update the record if date change it will be create the all record .so that i can keep what the excat value of all record in particular date..
if i am upadting any record in debtors with diffrent date like 1------a-----200000-------10/1/2001 to 1------a-----200000-------11/1/2001
it will be create all record of debtors in mastercopy object.
like
1------a-----20
0000-------11/1/2001
2------aa-----240000-------11/1/2001
3------aaa-----20000-------11/1/2001
4------aaaa-----30000-------11/1/2001
5------aaaaa-----60000-------11/1/2001
Please find the code below : If any of the case is not working than please le me know.
You can contact me on hangout at : abhishek.bansal@metacube.com.
Regards,
Abhishek
List<Debtors_Ledger__c> allDebtor = new List<Debtors_Ledger__c>([Select DailyUpdate__c,Name,Debtor_Name__c,Credit_formula__c,Debit_formula__c from Debtors_Ledger__c]);