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
Anil GanivadaAnil Ganivada 

Field id for custom report type filters

Hi,

   I am trying to capture the requests when filters are being set to Custom Report Type's report, basically I want to modify the fields to add more information to the filter fields if required. So when I add a filter to a report of standard report type it looks like this :

{"templateKey":"ReportAccount","ns":"","scope":"user","topn":0,"c":["USERS.NAME","ACCOUNT.NAME","TYPE","RATING","DUE_DATE","LAST_UPDATE","ADDRESS1_STATE"],"last_modified_user_id":"","sideBySide":false,"sortdir":"up","colorRanges":[],"format":"tt","currency":"000","created_by_user_id":"005j000000Bp3mo","charts":[{"ctsize":18,"ctitle":"","bgdir":"2","l":"1","bg2":16777215,"csize":3,"bg1":16777215,"tfg":0,"ct":"none","sal":false,"chco":false,"chsp":false,"cheh":false,"cp":"b","cfsize":12,"fg":0,"chst":false,"summaries":[],"chsv":false,"Yman":false}],"v":142,"co":"yes","last_modified_date":"","last_modified_by":"","details":"yes","customAggregates":[],"rt":"1","reportParams":[{"param":"colDt_c","value":"CREATED_DATE"},{"param":"colDt_e","value":""},{"param":"colDt_q","value":"custom"},{"param":"colDt_s","value":"3/16/2015"},{"param":"function","value":"c"},{"param":"name_op","value":"co"}],"cust_owner":"005j000000Bp3no","filters":[{"pc":"ACCOUNT.NAME","pn":"eq","pv":"hello world"}]}

the "pc" value in json indicates the fieldname on which a filter is being set. This works great because I know the field being used and can check if it needs to be updated with more information at proxy. However when a filter is set on a custom report type the request looks like this :

{"templateKey":"070j0000000bGeB","ns":"","scope":"user","topn":0,"c":["072j0000009iTW0","072j0000009iTXY"],"last_modified_user_id":"","sideBySide":false,"sortdir":"up","colorRanges":[],"format":"tt","currency":"000","created_by_user_id":"005j000000Bp3mo","charts":[{"ctsize":18,"ctitle":"","bgdir":"2","l":"1","bg2":16777215,"csize":3,"bg1":16777215,"tfg":0,"ct":"none","sal":true,"chco":true,"chsp":false,"cheh":false,"cp":"b","cfsize":12,"fg":0,"chst":false,"summaries":[],"chsv":false,"Yman":false}],"v":142,"co":"yes","last_modified_date":"","last_modified_by":"","details":"yes","customAggregates":[],"rt":"070j0000000bGeB","reportParams":[{"param":"colDt_c","value":"072j0000009iTWX"},{"param":"colDt_e","value":"3/31/2015"},{"param":"colDt_q","value":"current"},{"param":"colDt_s","value":"1/1/2015"},{"param":"function","value":"c"},{"param":"name_op","value":"co"}],"cust_owner":"005j000000Bp3mo","filters":[{"pc":"072j0000009iTW0","pn":"eq","pv":"hello world"}]}

The field which was set as filter in the above json highlighted is Account.Name, when I try to browse this id I get an error stating insufficient permissions. Can you kindly let me know where can I find mapping of this id to actual field in Salesforce.

Thanks in advance
tes2tes2

you could make a callout to the Metadata API in Apex.  See the metadataList method.  It will return  FileProperties[] that contains the mapping you seek for the reporttype Ids (070).  As for the (072) ids Im not fimiliar,  when looking at metadata of a reporttype xml I dont see these 072 (ids).  what is the source of the JSON?
Anil GanivadaAnil Ganivada
I tried to read list metadata I do not get FileProperties[] for the request :
 
      <met:listMetadata>
         <!--Zero or more repetitions:-->
         <met:queries>
            <met:type>ReportType</met:type>
         </met:queries>
         <met:asOfVersion>33.0</met:asOfVersion>
      </met:listMetadata>
I get the following response :
<result>
            <createdById>id</createdById>
            <createdByName>MM</createdByName>
            <createdDate>2015-03-19T23:40:46.000Z</createdDate>
            <fileName>reportTypes/JustAnotherReportType1.reportType</fileName>
            <fullName>JustAnotherReportType1</fullName>
            <id>070j0000000bGpmAAE</id>
            <lastModifiedById>005j000000Bp3moAAB</lastModifiedById>
            <lastModifiedByName>MM</lastModifiedByName>
            <lastModifiedDate>2015-03-19T23:40:46.000Z</lastModifiedDate>
            <manageableState>unmanaged</manageableState>
            <type>ReportType</type>
         </result>

I tried to read metadata with this call :
<met:readMetadata>
         <met:type>ReportType</met:type>
         <!--Zero or more repetitions:-->
         <met:fullNames>Test</met:fullNames>
      </met:readMetadata>

Which gives the table and columns but not the id's. Is there any other call in metadata API which I should look into ? 

The json is picked from the request generated when a user creates a filter and the request is submitted to salesforce.