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
AlanisticAlanistic 

Analytics reportchart

I've added the following code to my VF page:

<analytics:reportChart reportId="00Oc0000000aXNS" size="small"></analytics:reportChart>

The report is on cases and displays a pie chart.

The VF page displays details on a single selected account.  The chart however pulls in all cases regardless of account.  How would I amend the above code so that it only filters on the cases associated with the account being displayed on the page?

Best Answer chosen by Alanistic
bob_buzzardbob_buzzard
You'd use the filter attribute for this:

https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_analytics_reportChart.htm

In your case I think you'd need :

[{column:'ACCOUNT',operator:'equals',value:'<account_id>'}]

where you'd replace account_id with the id of the account in question.

All Answers

bob_buzzardbob_buzzard
You'd use the filter attribute for this:

https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_analytics_reportChart.htm

In your case I think you'd need :

[{column:'ACCOUNT',operator:'equals',value:'<account_id>'}]

where you'd replace account_id with the id of the account in question.
This was selected as the best answer
AlanisticAlanistic
Hi Bob, I looked at that previously, however this means the account is hard coded into the page.

The url for the page is essentially /AccountOverview?id=<accountid>

How can I capture the id being passed to the page and place that into the chart instead of hard coding the account id?
bob_buzzardbob_buzzard
That entirely depends on how your page works - is it standard controller, custom etc?  Can you post the page?
AlanisticAlanistic
The page uses the standard account controller but has an extension that pulls back contact information.  I've had a look at this link (https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AC5lIAG) for other details.

The page is very straight forward:

<apex:page standardController="Account" extensions="myAccountControllerExtension">
 
  <apex:pageBlock title="Account Details" mode="edit">
       
{!Account.Name}<br/>

</apex:pageBlock>

<apex:pageBlock title="Contacts">
         <apex:pageBlockTable value="{!cont}" var="con" >
            {!con.id}
            {!con.Name}
</apex:pageBlockTable>
            
        </apex:pageBlock>
       
  <apex:pageBlock title="Charts" mode="edit">
<apex:pageBlockSection columns="3">
                 <analytics:reportChart reportId="00Oc0000000aXNS" size="small" cacheResults="false" filter="{column:'Account.Name',operator:'equals',value:'{!Account.Name}'}" ></analytics:reportChart>              
            </apex:pageBlockSection>
         </apex:pageBlock>
 
</apex:page>


This displays the error on the VF page:

[For the filter 1: Specify a valid filterable column because Account.Name is invalid.]
Faiza Naz 10Faiza Naz 10
For those who might face this issue. I have a similar issue, but my requirment was to filter on custom object and its relationship. like Inventory__c.case__r.recordtype. Inventory custom object have case lookup and want to filter on its record type. So when i write like this
{column:'Inventory__c.case__r.recordtype', operator:'notEqual', value:''}
it says Specify a valid filterable column its solution is this.
{column:'FK_CASE_RECORDTYPE', operator:'notEqual', value:''} i was using inventory__c as standard controller on page and i get this solution from this post.

https://salesforce.stackexchange.com/questions/139890/embed-report-chart-to-visualforce-filter-issue

what actually happen is Salesforce has its own api names when you use them in filter which you can get by querying reports metadata.