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
26
votes
4answers
18k 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 ...
81
votes
2answers
15k 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 ...
22
votes
7answers
12k 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 ...
10
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 ...
15
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
14k 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 ...
8
votes
1answer
462 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 ...
7
votes
2answers
1k 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....
39
votes
12answers
59k 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: <...
18
votes
3answers
21k 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
756 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....
16
votes
2answers
21k 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. ...
14
votes
1answer
2k views

Creating/updating 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()...
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/...
1
vote
2answers
2k 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) <?...
8
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 ...
3
votes
2answers
397 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 ...
0
votes
1answer
2k views

Mass Delete flow and flow versions

I'm trying to delete some old flow which are inactive via workbench. DestructiveChanges.xml <?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce....
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 ...
14
votes
1answer
11k 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
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 ...
9
votes
4answers
7k 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 ...
12
votes
3answers
387 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 ...
10
votes
1answer
5k 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.
5
votes
3answers
20k views

How do I insert records in Custom Metadata Type through Apex?

I want to write a trigger on a custom object (Template__c) such that it invokes the creation or update of Custom metadata type records. Since the fields are not writeable, how do I achieve this? I ...
5
votes
2answers
224 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 ...
11
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 ...
9
votes
2answers
7k views

Metadata Deploy and Push fails on Flexipage componentInstances in API 49 (Summer 20) and later

I'm having a problem deploying metadata after having updated my project to Summer 20 and pushing the project contents to a Summer 20 org. There are several failures seemingly related to a FlexiPage ...
6
votes
1answer
637 views

Automate setup of an external identity provider via APIs

I use the Financial Force Metadata API Apex Wrapper to simplify an app setup using a custom UI. Part of the setup is the creation of a Self-Signed Certificate and its usage in a Single Sign-On Setting....
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 ...
9
votes
2answers
8k views

How to extract the application brand logo image over an API?

In API 38 (Winter '17), when an "App Branding" image is uploaded through the Lightning Experience UI, the app metadata includes this brand information: <?xml version="1.0" encoding="UTF-8"?> &...
7
votes
1answer
6k 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 ...
7
votes
2answers
852 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 ...
6
votes
1answer
1k 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 ...
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 ...
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?
3
votes
1answer
989 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 ...
3
votes
4answers
5k 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 ...
1
vote
1answer
730 views

How to use VSCode to find which reports are using a specific field

I have used Eclipse in the past but unfortunately, Eclipse and Force.com IDE no longer work for me. I have switched over to VSCode along with the Salesforce DX and forcecode extensions (among many ...
1
vote
1answer
470 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....
23
votes
5answers
28k 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 ...
19
votes
6answers
4k 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.
11
votes
3answers
7k 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 ...
19
votes
3answers
23k views

How do I get the length of a string field?

For a string field, is there a way to get the defined length of the field? For example say I allow a maximum of 10 chars, can I get that in apex? I am not asking how to get the length of a string (i....
9
votes
3answers
13k 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 ...