1

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...)

/services/data/v39.0/analytics/reports/id_here/describe/

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">
        <env:Header>
            <urn:SessionHeader xmlns:urn="http://soap.sforce.com/2006/04/metadata">
                <urn:sessionId>{{session_id}}</urn:sessionId>
            </urn:SessionHeader>
        </env:Header>
        <env:Body>
            <readMetadata xmlns="http://soap.sforce.com/2006/04/metadata">
                <type>Layout</type>
                    <fullNames>{{Layout Name}}</fullNames>
            </readMetadata>
        </env:Body>
    </env:Envelope>

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.