I'm wondering is that possible to execute the api code in apex anonymous window and go through all the elements without using any wrapper or any third party tools.

I'm trying to find out the column names for the reports like (Bucket field, column grouping, stored reports in folder etc...)


1 Answer 1


It is possible yes.

Here is an example get layout call from postman which you can use to create your code in Anon

<?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <urn:SessionHeader xmlns:urn="http://soap.sforce.com/2006/04/metadata">
            <readMetadata xmlns="http://soap.sforce.com/2006/04/metadata">
                    <fullNames>{{Layout Name}}</fullNames>

You just need to build the XML yourself and observe the following:

  1. Content-Type Header: text/xml
  2. SOAPAction Header: ""

Then it is just a matter of finding the right XML

Here is part of a create Button Example:

    '<upsertMetadata xmlns="http://soap.sforce.com/2006/04/metadata">' +

    '<metadata xsi:type="WebLink">' +
    '<fullName>{{objName}}</fullName>' +
    '<availability>online</availability>' +
    '<displayType>button</displayType>' +
    '<linkType>javascript</linkType>' +
    '<masterLabel>{{master_label}}</masterLabel>' +
    '<openType>onClickJavaScript</openType>' +
    '<protected>false</protected>' +
    '<url>{{button_url}}</url>' +
    '</metadata>' +

It can also be done from JS on a VF page as an example :

Set OAuthToken Without Apex Metadata Wrapper?

You must log in to answer this question.

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