function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PrazPraz 

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...

 

 

Best Answer chosen by Admin (Salesforce Developers) 
JimRaeJimRae

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

SPDSPD

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...

 

PrazPraz
Tnx so much..is there any solution to the second problem? Please tell me
SPDSPD
Ohh..im sorry i didnt read the second part....can you elaborate it?
JimRaeJimRae

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.

 

 

This was selected as the best answer
PrazPraz
Thank you su much Jim and SPD.....:smileyhappy: