Comments (8)
Issue resolved, see the code below ....
// Read the Layout
MetadataService.Layout OPMPlayout =
(MetadataService.Layout) service.readMetadata('Layout',
new String[] { MPButtonOpportunityLayout }).getRecords()[0];
// Add the Custom Button to the Layout relatedLists
if (OPMPlayout.relatedLists == null) OPMPlayout.relatedLists = new List<MetadataService.relatedListItem>();
MetadataService.relatedListItem relatedlistitem = new MetadataService.relatedListItem();
for (MetadataService.relatedListItem rlt: OPMPlayout.relatedLists) {
if (rlt.relatedList == 'RelatedLineItemList') {
relatedlistitem = rlt;
break;
}
}
if (relatedlistitem.relatedList == null) relatedlistitem.relatedList = 'RelatedLineItemList';
if (relatedlistitem.customButtons == null) relatedlistitem.customButtons = new List<String>();
relatedlistitem.customButtons.add('Mass_Price');
// Update the Layout
MetadataService.SaveResult[] OPMPresults = service.updateMetadata(new List<MetadataService.Metadata> { OPMPlayout });
from apex-mdapi.
@BoonPlus firstly, so sorry for not getting back to you sooner on this! Secondly well done on solving it, editing Layouts is probably one of the most complex bits of the API, so good for you for solving it and also thanks for sharing the solution back!
from apex-mdapi.
@afawcett No problems. I knew you're busy with Summerโ14 update to the Salesforce Metadata API. I was able to build some cool stuffs with the API, see the screenshot below ...
from apex-mdapi.
That is very very cool!
from apex-mdapi.
Do you have a Twitter account, i'd love to tweet this as an example if that's ok? If not, do you mind if i tweet it and just reference this GitHub issue?
from apex-mdapi.
@afawcett my twitter account is @BoonPlus, feel free to share this with your followers. Cheers!
from apex-mdapi.
@BoonPlus did you ever run into any issues with updating page layouts/related lists due to field visibility permissions; I'm getting a FIELD_INTEGRITY_EXCEPTION as you did here, but with a slightly different cause? Also on another note have you had any issues with deleting custom fields? I'm only asking you because I'm building functionality very similar to the tool you posted above. Any help would be much appreciated. Thanks in advance!
from apex-mdapi.
@cnaccio The field level permissions can be granted via the metadata api, which should be done before the field is added to the page layout. I haven't tried the deletefield method yet so I can't comment on it.
from apex-mdapi.
Related Issues (20)
- MetadataServiceExamples outdated
- Test Class For MetadatadeolpyController Class
- Help article to use named credentials with wrapper has been removed HOT 1
- Generate an Apex from WSDL
- GlobalValueSetTranslation HOT 2
- Update search layout task, event, activity HOT 1
- System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element customizeSetup
- Apex Wrapper Metadata API Takes Time to Reflect the Change
- Can't create in production org
- Can't create a sharing rule HOT 2
- GlobalValueSetTranslation
- Can we create ApexClass natively? Any Example? HOT 1
- UserInfo.getSessionId() makes this unusable in packaged code HOT 2
- How do we update multiple profiles at once?
- LightningComponentBundle (LWC): reading/creating/updating
- Creating Apex Trigger
- Creating a MultiPicklist HOT 2
- System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element includeRecordsOwnedByAll
- How To get Picklist Value according to record type for a custom object HOT 3
- Can anyone suggest on how to read the flexipage? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apex-mdapi.