This may be an 'XY Problem' question but is there a way to edit reports through an API?

The scenario is as follows: Our managed package has several reports with filters using custom values on the Opportunity.Stage picklist. The problem is that the Opportunity.Stage picklist is a Standard Value Set, and as per the Metadata Coverage Report Standard Value Sets cannot be included in packages. Therefore, when we install our package the custom values in the Opportunity.Stage picklist aren't included and so our reports with filters for those values are just ignored. The report will be created but the filter is dropped.

We can't insert the picklist values before installing our package because we want to include them as part of our Sales Process to ensure we don't affect the other opportunities in the system not related to our product. Upgrading the product doesn't seem to help either.

We can add the report filters manually after install but we're trying to eliminate as many manual steps as possible. Scaling this would be a pain.

The question is - can we edit reports via Apex or an API to at least make this more repeatable and less manual?

If the above question is a no, and anyone has alternative solutions to the above I'm all ears :)

1 Answer 1


Unfortunately you can't modify a report via API or Apex.

What you could do to automate the report update is:

  1. retrieve the report metadata with the Salesforce CLI or the metadata API
  2. edit the report XML to inject your picklist values with a script on your local machine
  3. re-deploy the updated report metadata
  • Hey @POZ cheers for the quick response. That makes sense as we can still edit the reports through the metadata API so maybe that's the best approach to automate. Thanks
    – Shane Bird
    Commented Oct 6, 2021 at 13:04
  • Digging deeper into this I'm not sure it's a perfect fit as the reports are in a managed package and so any pushes through the CLI/ metadata API won't be directly on the managed reports themselves, instead duplicating them. This is probably something we'd run into regardless though
    – Shane Bird
    Commented Oct 6, 2021 at 13:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .