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
Patrick NylenPatrick Nylen 

Chart embedded on Visualforce page opens in edit mode

Hello,

I'm using the reportChart component to embed a chart on a Visualforce page. When clicked, though, the report opens in edit mode and, while the filters are visible in the URL, clicking Run Report then shows the unfiltered report.

See my example below. The issue seems to be the "THIS YEAR" value in the second filter. When replaced with an actualy date (e.g. "2016-01-01") everything works fine. Is there another way to reference "this year"?

<analytics:reportChart reportId="xxxxxxxxxxxxxx" showRefreshButton="false" size="medium" cacheResults="false" filter="[{column:'Custom_Field__c', operator:'equals', value:'Value1,Value2,Value3'},{column:'Custom_Date_Field__c', operator:'equals', value:'THIS YEAR'}]"></analytics:reportChart>
Alain CabonAlain Cabon
Hi,

Did you test THIS_YEAR ?

{column:'Custom_Date_Field__c', operator:'equals', value:'THIS_YEAR'}

I have tested the following filter and it is correct for CREATED_DATE:

filter="[{column:'CREATED_DATE', operator:'equals', value:'THIS_YEAR'}]"

Regards
Patrick NylenPatrick Nylen
Thanks -- yeah, did test THIS_YEAR that but no luck.

The ugly workaround: using 2 filters to dynamically constrain the results to the current year:

{column:'Custom_Date_Field__c', operator:'greaterThan', value:'{!YEAR(TODAY())-1}-12-31}'},
{column:'Custom_Date_Field__c', operator:'lessThan', value:'{!YEAR(TODAY())+1}-01-01}'}
Alain CabonAlain Cabon
Ok, with a custom field, you have to add the name of the object like below (here it is Account): 
<apex:page >
    <analytics:reportChart reportId="00O580000035JGm" showRefreshButton="false" size="medium" cacheResults="false" filter="[{column:'Account.SLAExpirationDate__c', operator:'equals', value:'THIS_YEAR'}]"></analytics:reportChart>
</apex:page>

That should work. This test is correct.

Regards
Alain CabonAlain Cabon
/services/data/v39.0/analytics/reports/00O580000034JGn/describe

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_analytics_reportChart.htm
 
<apex:page >
    <analytics:reportChart reportId="00O580000034JGn" showRefreshButton="false" size="medium" cacheResults="false" filter="[{column:'Account.SLAExpirationDate__c', operator:'equals', value:'THIS_YEAR'}]"></analytics:reportChart>
</apex:page>


User-added image

User-added image

That works but the values appear in the results of the describe command.

Regards