How can i identify the value for pc on report parameters when i use pc, pn and pv parameters to filter on the report? I am able to identify the names of standard fields, but unable to parse the custom fields and lookup fields.
-
What are pc, pn, and pv?– Shumon SahaJun 16, 2013 at 15:19
-
pc is the field that you want to filter on pn is the operator and pv is the filter value. Eg: To build Case status = Open as a filter on a report, you would add pc0=Case.Status&pn0=eq&pv0=Open as url parameters.– GaneshJun 16, 2013 at 17:49
2 Answers
Custom fields will use the custom field Id. It will start with the key prefix 00N.
You can get the ID be browsing to the custom field in the App Setup and grabbing the ID from the query string.
E.g. https://na.salesforce.com/00O7000000xxxZG?pc0=00N70000001pOah&pn0=eq&pv0=true
Alternative method
Manually add a filter to the report on the required field:
E.g. Filter a Contacts report by related Account Name
You can then run the filtered report and extract the applicable pc*, pn*, and pv* values from the hidden inputs in the HTML source.
Here I'm using the Chrome developer tools to search for the "Testing" value I put in the filter.
-
Thanks for the answer but that doesn't seem to work. Also, my object in question has multiple lookup to user and the report type brings in the same field from the different lookups. So if i use the field id, the system will still be confused as to which lookup it should refer to. For fields via lookup, is there anything else that needs to be used?– GaneshJun 17, 2013 at 10:36
The filter Ids are specific to that Report Type. To find them, View Page Source on the report you're planning to hack. You will see a section of code something like this:
<optgroup label="Account: Address"><option value="ADDRESS1_LINE1">Billing Address Line 1</option>
<option value="ADDRESS1_LINE2">Billing Address Line 2</option>
<option value="ADDRESS1_LINE3">Billing Address Line 3</option>
</optgroup>
<optgroup label="Account: Custom Info"><option value="00Na0000009SDEn">_SYSTEM: AccountType</option>
<option value="00Na0000009SK3I">Primary City</option>
<option value="00Na0000009SK4Q">Primary Country</option>
...
<option value="00Na0000009SK4L">Type</option>
</optgroup>
Depending on the Report Type and the particular field, they may be the field Ids (prefix 00N
as above) or reserved words, or they may be Ids unique to that Report Type. In some cases, the Id in the page source will look like FK_00Na0000009SK4L
, and it has been important to use the FK_
.
If your report type doesn't use the field Ids and has some other kind of Id in there, you will likely have to grab these values out of the page source directly. I have seen Ids that look like 072A0000002s6JU
, that don't seem to be referenced anywhere else in the org. Anecdotally it seems to be only older Custom Report Types that use these different Ids.