Questions tagged [metadata-api]

Questions about the Metadata API provided by salesforce. The API that can be used to retrieve, deploy, create, update or delete customization information, such as custom object definitions and page layouts, for your organization. This API is intended for managing customizations and for building tools that can manage the metadata model, not the data itself.

Filter by
Sorted by
Tagged with
22
votes
3answers
13k views

Getting Session ID in Lightning

Background I'm using Apex Wrapper Salesforce Metadata API to update some picklist values on the fly. (i.e. Every time a record is inserted/updated/deleted in Table A, I'm adding/subtracting picklist ...
80
votes
2answers
13k views

Has anyone, ever, successfully invoked the Metadata API from within Apex?

While researching a semi-related question posted here earlier, I dug up some interesting and conflicting information regarding whether it's even possible to use the Metadata API from within Apex. I ...
8
votes
1answer
3k views

How do I Call the Salesforce API from a Lightning Component?

I have a requirement to make a call to the Apex Wrapper Metadata API from a Lightning component. The issue I am facing is that there is currently no native support for acquiring a valid API session ID ...
21
votes
7answers
11k views

How to get a list of the managed packages (including version numbers) installed in an org?

For a continuous integration setup, I only want to install/upgrade some packages (through the new InstalledPackage mechanism) when necessary. I've looked at the Metadata WSDL (and documentation) and ...
14
votes
2answers
3k views

Lightning: is direct API access on the roadmap?

I'm programming developer tools and an IDE. Right now, my code is based on Visualforce and JavaScript. As described here, I would like to convert most of my API callouts form APEX to JavaScript. Also ...
16
votes
1answer
13k views

Using Meta data api in apex

i know if u have to create a field in apex then u have to call meta data api of salesforce.i found only this link for implementation https://github.com/financialforcedev/apex-mdapi is there any other ...
30
votes
9answers
41k views

How to debug the mysterious “duplicate value found: <unknown> duplicates value on record with id: <unknown>” error

I've just spent several hours trying to fix a deployment that was failing with the following extremely helpful error message: Error: objects/Opportunity.object(2098,13):duplicate value found: <...
16
votes
3answers
13k views

How to push code to production with Visual Studio Code & DX

I am using Visual Studio Code to develop new functionality. However, after completing the testing in the sandbox, I want to push the code to production. When I choose "SFDX: Deploy Code to org", it ...
13
votes
2answers
15k views

How to retrieve layouts of customs objects belonging to a managed package?

I am trying to retrieve the layouts of all(standard + custom) objects from a test Enterprise org using package.xml manifest files. There are some customs objects that I have created on this org. ...
5
votes
1answer
155 views

Is it possible to programmatically change connectedApp settings in production?

Background: I have a requirement to make it so that an SFDC connected app defaults/is super easy to set to Admin Users are Pre-authorized instead of All users may self-authorize. This setting is ...
5
votes
2answers
550 views

Metadata API Apex fails to create fields in Connected App

I am using the latest v46 version of the Financial Force Metadata API Apex Wrapper to create a Connected App but the values I put in the code are partly ignored. What is not working: ConnectedApp....
3
votes
1answer
3k views

ant deploy error - Maximum size of request reached

I used to deploy metadata using ant migration tool successfully but from last night I am getting the below error: John@John:~/mm_workspace/TEST_Project/deploy$ ant deployUnpackaged Buildfile: /home/...
7
votes
2answers
7k views

Set Field Level security for profile using meta-data api

I am using meta-data api to create custom fields in java class. Now I want to set field level security for different profiles. First is it possible to set this with meta-dat api, If yes than how can I ...
11
votes
3answers
7k views

How to Search Workflow Rules or Validation Rules etc in Apex i.e. Metadata Search via Apex?

Recently I'm working on building something for developers/administrators - a handy 100% force.com app allowing to search metadata. Currently this app allows you to quickly search (from sidebar) custom ...
13
votes
1answer
1k views

Possible to update NamedCredential from Apex?

Question Is it possible to create or update a NamedCredential from within Apex? Investigation I looked into available options, and it seems the SOAP API only supports the describeSObjects(), query()...
9
votes
1answer
5k views

REST API: How to update active values for picklist?

I need to update the Picklist values for a custom field on a custom object. I have already populated the Available Values via the Enterprise and Metadata Java APIs, but now I need to move the newly ...
3
votes
2answers
331 views

Set OAuthToken Without Apex Metadata Wrapper?

In working through an answer to this question, I found that I can set the oauthToken value on a NamedCredential using an Apex wrapper for the Metadata API. However, as far as I am aware, that still ...
14
votes
1answer
2k views

Access MetadataAPI via JavaScript

We created an 100% native Salesforce IDE as a Managed Package which is using ToolingAPI and MetadataAPI via APEX. This works fine. But there is one thing which really bothers people after the ...
21
votes
1answer
6k views

difference between metadata and tooling API

What is the difference between metadata API and tooling API? When I read the documentation, they both appear the same to me from the metadata perspective. I would like to know how I can use it for ...
13
votes
1answer
9k views

Deleting custom object via destructiveChanges.xml and Metadata API deploy()

I've created a custom object in a developer edition org with the sole intention of deleting it via the Metadata API as per Deleting Components from an Organization. To do this I created the following ...
12
votes
2answers
293 views

Initiate an oAuth flow via an Auth Provider

I use the Metadata API and the Apex wrapper to create an AuthProvider and NamedCredential after the installation of my managed package app. MetadataService.NamedCredential cred = new MetadataService....
11
votes
1answer
6k views

Dynamically set remote site Setting in Apex

I have created a managed package that uses tooling API for updating class, trigger etc. Everything runs fine with all sorts of testing. I have created this package in my Developer org. I had to set ...
12
votes
3answers
382 views

Metadata+ToolingAPI access on CS14 (and other pods) extremly slow & No Support?

We are working on CS14. Starting last Friday we are suffering form a extreme performance loss on CS14. Loading and Saving Metadata via Tooling/Metadata-API is very slow. Operations which usually ...
5
votes
2answers
222 views

EU5 not usable for development: Metadata-API deployment on EU5 unresponsive

Today I encounter a severe performance degradation on Metadata-API deployment speed on EU5. I'm waiting > 950 seconds (sometimes > 1500 seconds), when it usually deploys in < 25 seconds... This is ...
8
votes
1answer
3k views

How do I update Custom Label's value using apex? Which one would be a better option metadata api or tooling api? Please provide example

I'am working on post deployment automation process in salesforce. I am stuck on how should I update values in custom labels which needs tobe updated manually after a sandbox refresh.
3
votes
2answers
1k views

How to read a ListView (restricted Visibility to me) with APEX MetadataService.cls?

During my work on this question, I'm trying to retrieve a ListView using this code: public class SFSEMetadataListView { public static void readListView() { MetadataService.MetadataPort ...
7
votes
1answer
4k views

How to specify what components to retrieve for the command “force:mdapi:retrieve”?

I am just getting started with sfdx and trying to retrieve all the metadata present in my sandbox using the command sfdx force:mdapi:retrieve --retrievetargetdir force-app. It runs fine and creates a ...
7
votes
3answers
3k views

Override Eclipse Metadata API Version

Is it possible to override the eclipse metadata api version? Often new details are available via the metadata api before the latest eclipse ide update (assuming that they actually include new stuff ...
6
votes
1answer
987 views

Anyone else having issues with deployment to sandbox stuck in pending for 5-60 minutes

Developing in two sandboxes and both of them when I attempt to deploy anything via metadata or tooling API the deployment is stuck in a pending status from 5-60+ minutes. I have a case open for one ...
6
votes
2answers
396 views

Email Service via Metadata API fails to create from Managed Package

As Email Services can't be packaged in a Managed Package, I allow subscribers to create it after the installation. The code which works in my packaging org fails in productions orgs with: An Apex ...
5
votes
1answer
1k views

How do i retrieve all installed packages names through API?

I am using RetrieveRequest object to retrieve packaged and unpackaged components. Part of the code is: String[] packageName = {"Salesforce for Google AdWords"}; RetrieveRequest retrieveRequest = new ...
5
votes
2answers
2k views

Retrieve Force.com registered domain

I need to return this value: Is there anyway to get the registered Force.com domain for a given org, with raw Apex code or Metadata API?
5
votes
1answer
3k views

Failing to update picklist on task object via metadata API

I am using the metadata API from Apex code thanks to Andrew Fawcett's very helpful code to do this. I have a some Apex code that goes and updates a series of multiselect picklists with the same set of ...
3
votes
4answers
4k views

How to know if a custom field is referenced in Workflow or Validation rule using Metadata API?

Is there any way to find out if a field is used in Workflow or not. I tried working with Metadata API's listMetadata call which returned me file properties . But no information about Field referenced ...
3
votes
1answer
911 views

How to fetch a layout from metadata API in apex under a name prefix

Following my previous question: Updating page layout related list using metadata api Yes, after three days' headache, I am still investigating this issue. I have created a new dev org and copied ...
1
vote
2answers
1k views

deploying and retrieving Address settings (State & Country picklists)

I'm having problems understanding how to deploy Address.settings with the Metadata API. As in: how do I structure the package.xml? I have this as Address.settings (shortened for brevity) <?...
1
vote
1answer
389 views

MetadataAPI: Missing MetadataPort.checkStatus(String[] asyncProcessId) in MetadataService.cls v32.0

I'm updating MetadataService.cls form a older version for v29 to the current version v32 and found some members maybe missing: MetadataPort.checkStatus(String[] asyncProcessId) MetadataPort....
20
votes
5answers
24k views

Generate complete package.xml for Org

I'm using the Force.com Migration Tool for Ant more and more. I currently have several organizations at different API versions (release previews, for example). Is there a way to generate a complete ...
17
votes
6answers
3k views

How to keep sandbox in sync with changes from other developers?

We are a team of 9 developers, working on a large project and commits are made to master branch all the time. When I needed to work on any new enhancement I used to pull everything from master branch ...
20
votes
4answers
5k views

Ant vs other deployment tools

I am wondering if there are any use cases for using Ant specifically over all other deployment methods and tools? It seems Eclipse, changesets and packages have all the functionality you need.
10
votes
3answers
5k views

Metadata API Custom Field Permissions (how to automate this process)

We are using the Metadata API to add Custom Fields to the Account object in Salesforce. We are able to create the custom fields, but then the Salesforce user has to manually login to their account ...
9
votes
4answers
6k views

Are profile and permission set metadata files getting all project objectPermissions?

I have a project in development. There about 45 new SObjects to the org but there is also a couple of new profiles for the org. The permissions on several existing SObjects have been specifically ...
4
votes
1answer
1k views

Is anyone getting deployment issues with Task object? New list views from 46 causing errors

When I'm trying to deploy the native Task object to another sandbox, I am getting errors: objects/Task.object (Task.CompletedTasks) -- Error: Value too long for field: Name maximum length is:40 (...
9
votes
3answers
12k views

Full List of All Accessible Types Through Metadata Api

I am looking for some official Salesforce documentation on a list of all available types in the metadata API. If I am using a package.xml file that looks like: <?xml version="1.0" encoding="UTF-8"?...
8
votes
1answer
2k views

Is there a Javascript Wrapper Salesforce Metadata API?

I'm using Andrew Fawcett's legendary Apex Wrapper Salesforce Metadata API in several projects. It perfectly works and provides a new dimension of APEX programming. Now there are situations where it ...
5
votes
1answer
1k views

Must specify a {http://www.w3.org/2001/XMLSchema-instance}type during creating Approval process using metadata API

I am trying to create Approval process using Metadata API but unable to figure out what i am missing. One doubt is XML don't have any symbol why which me or Salesforce could identify on which object ...
4
votes
3answers
2k views

How to query metadata changes in a sandbox based on dates

We are trying to compare our development sandboxes now which have become totally out of sync because of changes done by independant teams for a few releases. Do you guys know of any free apex code ...
2
votes
2answers
773 views

Is there a way to query sandbox configuration info? (e.g. Location, sandbox name, etc)

I would like to be able to query the Sandbox configuration data. For example, if you go to the "Sandboxes" link in the setup of your production org, I want to be able to query that info (Name, Type, ...
8
votes
1answer
3k views

How can I activate a Lightning Page via metadata?

I am deploying a solution which includes Lightning Pages and I would like to programmatically activate the FlexiPage in the target org when it is deployed. In the Configure Lightning Experience ...
8
votes
1answer
2k views

Updating profile via Metadata API from Apex gives weird error

I am trying to automatically enable pages for profiles (profileApexPageAccess doc) via Metadata API. Here is my method: public static void updateProfileAccesses(String profileName, List<String> ...