I'm attempting to use the Metadata API to add a custom button to my contact layout:
https://github.com/financialforcedev/apex-mdapi/
I'm following the example written here: https://andyinthecloud.com/2014/04/24/apex-metadata-api-and-spring14-keys-to-the-kingdom/
To begin, I copied the MetadataService.cls and MetadataServiceTest.cls into my force.com developer instance. Then, I attempted to run through the example by first creating a webLink MetadataService, however when I get to the last line it gets stuck:
MetadataService.WebLink webLink = new MetadataService.WebLink();
webLink.fullName = 'Test__c.googleButton';
webLink.availability = 'online';
webLink.displayType = 'button';
webLink.encodingKey = 'UTF-8';
webLink.hasMenubar = false;
webLink.hasScrollbars = true;
webLink.hasToolbar = false;
webLink.height = 600;
webLink.isResizable = true;
webLink.linkType = 'url';
webLink.masterLabel = 'google';
webLink.openType = 'newWindow';
webLink.position = 'none';
webLink.protected_x = false;
webLink.showsLocation = false;
webLink.showsStatus = false;
webLink.url = 'http://www.google.com';
webLink.width = 600;
service.createMetadata(new List<MetadataService.Metadata> { webLink })[0];
I am getting the error "Entity is not api accessible". This is my first time using the Metadata API and I'm not really sure how to troubleshoot this. Any suggestions?
Deploy to Salesforce
button on the github page that leads to this page.