ejholmes / metaforce

A ruby client for interacting with the Salesforce Metadata and Services API's.
https://github.com/ejholmes/metaforce
MIT License
65 stars 75 forks source link

Passing parameters to metadata calls #43

Open boxfoot opened 11 years ago

boxfoot commented 11 years ago

I'm trying to get a list of reports, and can't figure out how. The basic call should be something like:

objects = client.list_metadata "Report" 

but I can't figure out how to add in the parameter for report folder. Is this supported?

Related: listMetadata allows submitting up to three ListMetaDataQuery queries with each call. Is there a way to do that with metaforce?

ejholmes commented 11 years ago

Aren't Reports records? You'd probably be better off using Restforce

boxfoot commented 11 years ago

Reports (and Documents, EmailTemplates) are both records and metadata. I'm writing a utility to generate package.xml files, which means using metadata API to query for data types. Most types allow subscription with *, but these types require the use of listMetadata while specifying a folder name. While I could use Restforce to complement Metaforce, it should be possible to build the utility using just the Metadata API, so I'd like to do that if possible. See http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_report.htm.

chexxor commented 11 years ago

I don't have a solution, but maybe this is useful.

I also want an easy way to pull down all Folder-based metadata

Here are some blog posts that detail some strategies: http://www.pocketsoap.com/weblog/2008/10/1826.html http://wiki.developerforce.com/page/Syncing_Salesforce_Org_Metadata_to_Github

To pull the actual metadata files locally, I should be able to do something like this:

    manifest = Metaforce::Manifest.new({:document => ['MyFolder', 'MyFolder/MyDocument']})
    client.retrieve_unpackaged(manifest).extract_to('./tmp').perform

We can't use '*', so we have to be specific with our metadata request. So, we still need to get a list of an org's folders, and all items in these folders. This SOQL query should get the folder names:

    SELECT Id, Name, DeveloperName, Type, NamespacePrefix, AccessType
    FROM Folder
    ORDER BY Name DESC

Then to get the items in these folders, we have to query data records for folder-based metadata, which is Reports, Documents, Dashboards, and EmailTemplates:

    SELECT Id, Name, DeveloperName, IsDeleted, NamespacePrefix
    FROM Report
    ORDER BY Name DESC

I don't have good base knowledge in this area, so I don't know what the problem is. A problem with my org's security settings for my folder-based metadata? A problem with Metaforce? A problem with the Metadata API?