You need to sign in to do that
Don't have an account?

SOQL Query and Report display problem
Hi,
I have the following Query where I want to get latest and oldest date of entry how can I get that
Date dat= [select max(Pack__Date_of_Entry__c) from Pack__TCI__c].Pack__Date_of_Entry__c; Date dat= [select min(Pack__Date_of_Entry__c) from Pack__TCI__c].Pack__Date_of_Entry__c;
But the aggregate function does not seem to be working on Date type
Secondly, I want to display an already generated report in a visualforce page I have developed. Is it possible if yes please tell me how...
I think SPD has a great solution to the first question, you can get away with one query.
If you wanted 2 queries, you could also use the limit modified to get your desired result.
Date dat= [select Pack__Date_of_Entry__c from Pack__TCI__c order by Pack_Date_of_Entry__c desc LIMIT 1].Pack__Date_of_Entry__c; Date dat= [select Pack__Date_of_Entry__c from Pack__TCI__c order by Pack_Date_of_Entry__c asc LIMIT 1].Pack__Date_of_Entry__c;
For the report, there is no easy way to do this in an elegant manner.
One solution you could use, is to render the report in an iframe tag, this unfortunately, will not just show the report, but will show the header and sidebar as well.
To do this, you create and save your report. execute it, and copy the URL. Use this URL as the src parameter of the iframe tag.
<apex:pageBlock> <apex:iframe scrolling="true" src="https://cs3.salesforce.com/00O70000009cX2B"/> </apex:pageBlock>
There is also an interesting article (from 2006) about "scraping" a report by extracting the XML from the stream as the report is rendered.
Here is the link:
http://sfdc-heretic.warped-minds.com/2006/04/10/progmatic-access-to-salesforcecom-reports/
I never got it to work, but maybe you will have more luck.
All Answers
you will probably need to do the following :
List<Pack_TCI__c> lst = [select Pack_Date_of_Entry__c from Pack_TCI__c ORDER by createdDate ];
Date latestDate = lst[lst.Size() - 1];
Date oldestDate = lst[0];
i hope this works...
I think SPD has a great solution to the first question, you can get away with one query.
If you wanted 2 queries, you could also use the limit modified to get your desired result.
Date dat= [select Pack__Date_of_Entry__c from Pack__TCI__c order by Pack_Date_of_Entry__c desc LIMIT 1].Pack__Date_of_Entry__c; Date dat= [select Pack__Date_of_Entry__c from Pack__TCI__c order by Pack_Date_of_Entry__c asc LIMIT 1].Pack__Date_of_Entry__c;
For the report, there is no easy way to do this in an elegant manner.
One solution you could use, is to render the report in an iframe tag, this unfortunately, will not just show the report, but will show the header and sidebar as well.
To do this, you create and save your report. execute it, and copy the URL. Use this URL as the src parameter of the iframe tag.
<apex:pageBlock> <apex:iframe scrolling="true" src="https://cs3.salesforce.com/00O70000009cX2B"/> </apex:pageBlock>
There is also an interesting article (from 2006) about "scraping" a report by extracting the XML from the stream as the report is rendered.
Here is the link:
http://sfdc-heretic.warped-minds.com/2006/04/10/progmatic-access-to-salesforcecom-reports/
I never got it to work, but maybe you will have more luck.