function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Leonardi KohLeonardi Koh 

updating CustomFieldMetadata with tooling API?

So i've been trying to update the CustomField metadata using Tooling API through Apex class, but i have no idea if this is actually possible.

What i've done so far is:
String endpoint = 'https://XXX.salesforce.com/services/data/v41.0/tooling';
String param = '/sobjects/CustomField/{Custom Field Id}?_HttpMethod=PATCH';

HttpRequest req2 = createHttpRequest(endpoint+param, 'POST');
req2.setBody('{"Metadata":{"summaryFilterItems":[{"field":"MyObject__c.MyField__c","operation":"greaterThan","value":"1/01/2018"}]}}');

String responseJSON2 = getResponse(req2);
...
private HttpRequest createHttpRequest(String endpoint, String method) {
        HttpRequest req = new HttpRequest();        
        // endpoint += '';
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/json');
        req.setEndpoint(endpoint);
        req.setMethod(method);
        return req;
}
...
private String getResponse(HttpRequest req) {
        try {
            Http httpreq = new Http();
            HttpResponse res = httpreq.send(req);
            String reqresponse = res.getBody();
            return reqresponse;
        }
        catch (Exception e) {
          return 'Error:' +e.getMessage();
        }
}

But i've been constantly rejected by Tooling API indicating that they could not resolve the standard field name

Does anyone have any luck with this kind of process in Apex?