1

I'm trying to use the reportFilters URL parameter to dynamically filter reports in a Lightning Community. A user clicks the custom link on a certain record and it opens the community report page filtered for the record they started from. I haven't found any documentation about this feature, but found it in a few forums.

FYI - the normal fv0 parameter doesn't work in Lightning communities.

When I click my link, I get the following error:

For the filter 2: Specify a valid filterable column because Session_Online_Registration__c$BOKS_Session__c is invalid.

Working Custom Link:

Filtering for a certain account on a report type that looks at account and a master-detail child object.

/community/s/report/00O000000000000?reportFilters=[{%22column%22:%22ACCOUNT.NAME%22,%22operator%22:%22equals%22,%22value%22:%22{!Account.Name}%22}]

Link that's Not Working:

Filtering for a certain Session (custom object) on a report type that looks at Session and a master-detail child object.

/community/s/report/00O000000000000?reportFilters=[{%22column%22:%22Training_Session__c.Name%22,%22operator%22:%22equals%22,%22value%22:%22{!Training_Session__c.Name}%22}]

I've tried a lot of variations on the Column, including:

  • Session_Online_Registration__c%24BOKS_Session__c
  • Session_Online_Registration__c$BOKS_Session__c
  • Training_Session_c.Id
  • I even tried editing it to filter for ACCOUNT.NAME, which these objects also look up to, but it didn't work. I've made sure the source report contains the related lookup column.

3 Answers 3

2

today I've encountered the same issue. The 'Column' is not the same as any logical API reference we are aware of. The work-a-round which did work (though it requires a bit of developer-knowledge).

  1. Update the Report to have the filter you want to set dynamically
  2. Retrieve the Report .xml file via the metadata API
  3. Open that file and search for the criteria. In there you'll see the column name which you can use.

In my scenario I had a custom object and for Id and Name I retrieved:

  • Custom_Object__c.Id > CUST_ID
  • Custom_Object__c.Name > CUST_NAME

A valid URL was:

/{communityName}/s/report/00O1x000000JTQhEAO?reportFilters=[{%22column%22:%22CUST_ID%22,%22operator%22:%22equals%22,%22value%22:%22{!recordId}%22}]
2
  • can you post the report metadata that shows CUST_ID and CUST_NAME? I have a report on a custom object Occasion__c and my filter metadata has only Occasion__c$Id, I don't see all-caps names like you mention. Oct 25, 2019 at 16:27
  • This seems to be same same for "Custom Object" "ID" or "NAME". Both "CUST_NAME" and "CUST_ID" worked for me on multiple custom objects. Looks like using the metadata API to gather the name allows you to make this approach work. The filters do have to be displayed on the report for this approach though.
    – Chris
    Nov 12, 2019 at 12:07
0

Expanding on Reinier's answer - I have also found that for community users, you must remove the original filter condition from the report in order for the URL filter condition to be applied correctly. If you leave the filter condition in the report, the URL filter does not change it - instead, it adds a "linked filter" to the filter conditions. But that means the original filter overrides the linked filter and it doesn't work.

Example: Say your report has a filter condition of Id = "" (blank). If you pass in a URL filter condition to set the ID, you end up with original filter Id = "" and linked filter Id = a1l3F000000kxg4QAA and you get no results.

If you remove the original filter from the report, then only the linked filter is in effect and you get the correct results.

0

@DavidCheng please find some documentation on the Report metadata. I'm not sure why you didn't see those capital-CUST fields, although I did find this is only for standard parent fields (which are part of the Report Type). Object fields are specified in the 'normal' approach.

The three filters added to the Report and shown in metadata.

Report FiltersReport Metadata

As you can see the Dealer Contract fields (parent - master detail) are resulting in CUST_NAME and CUST_OWNER_NAME, while the EndDate field on the Allocation is specified as we normally reference a field. Report Type here was set to Dealer Contract with Allocations.

And I do fully agree on the removal need of the filter, as the Community approach adds a filter condition itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.