• Tal Cohen
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 2
    Questions
  • 0
    Replies
I Use the Metadata API to read, analyze, edit and create/update reports.

I noticed that the field names (when specifying columns, filters, and groupings) which are returned when reading are not always the same names, and seem to depend upon Report Type.

Suppose I create a simple report on accounts, and I only return two columns, Account owner and Account Name.
1. If I chose standard system-generated "Accounts" report types when creating this report, then upon reading it in the metadata API the column names are
ACCOUNT.NAME, USERS.NAME

2. If I chose custom report type which I created manually, then the column names are (These seem to be the API names)
Account.Name, Account.Owner.Name

3. If I choose a system-generated report type where account is not the main object, for example "Activities with Account" I get the following column names:
ACCOUNT.NAME, ACCOUNT_OWNER_NAME

This happens with other (not custom) columns as well. Maybe there are even more possible column names for the same column in different report types, I don't know...

How to know when to use which names? Also, Is there a way I read the other (besides API, option 2) column names programmatically? Can't find these names in the describe when using Partner or REST API.
Hi,
I want to programmatically create a report with several filters, and I'm not sure how to correctly do this via Report API.
Note : The report type (objects returned in the report) are dynamically chosen by the user, so I don't know in advance whether this is going to be a report on Leads \ Opportunities \ Accounts \ Custom object etc.

My options as far as I see :
   - Use the QUERY method to run a report - but then, how can I save this report for later use? (Documentation says it's not saved)
   - Create a dummy report manually, then use PATCH method to change an existing report - tried this, but it seems I cannot change the reportType field (I get an error saying "INVALID COLUMN" when trying to change an Opportunities report  to a Leads Report

Am I missing something?
I Use the Metadata API to read, analyze, edit and create/update reports.

I noticed that the field names (when specifying columns, filters, and groupings) which are returned when reading are not always the same names, and seem to depend upon Report Type.

Suppose I create a simple report on accounts, and I only return two columns, Account owner and Account Name.
1. If I chose standard system-generated "Accounts" report types when creating this report, then upon reading it in the metadata API the column names are
ACCOUNT.NAME, USERS.NAME

2. If I chose custom report type which I created manually, then the column names are (These seem to be the API names)
Account.Name, Account.Owner.Name

3. If I choose a system-generated report type where account is not the main object, for example "Activities with Account" I get the following column names:
ACCOUNT.NAME, ACCOUNT_OWNER_NAME

This happens with other (not custom) columns as well. Maybe there are even more possible column names for the same column in different report types, I don't know...

How to know when to use which names? Also, Is there a way I read the other (besides API, option 2) column names programmatically? Can't find these names in the describe when using Partner or REST API.
I know about Salesforce Reports and Dashboards REST API. But Report REST API allows only to change (update) an existing report by sending PATCH request with appropriate json body and clone a report based on existing one by sending POST request. But I need to create a new Report, not cloned report.
Also I tested dashboard creation by sending POST request with appropriate json body on the url https://ap2.salesforce.com/services/data/v37.0/analytics/dashboards and it works. But the same doesn't work for the Report. After sending POST request on the url https://ap2.salesforce.com/services/data/v37.0/analytics/reports I got a response:
[ 
  { 
     "errorCode": "BAD_REQUEST",
     "message": "The clone request must contain a valid cloneId parameter." 
  }
]
It means that I cannot create new Report by sending POST request to the REST resource.
Also I tried to create report by upsert and insert methods of SOAP Partner API, but in the response result I got the next message:
<message>entity type cannot be updated: Report</message>
<statusCode>CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY</statusCode>
Have anybody ideas the way of report creation via Salesforce API?