Giter Site home page Giter Site logo

Comments (8)

BoonPlus avatar BoonPlus commented on July 30, 2024

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.

afawcett avatar afawcett commented on July 30, 2024

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

BoonPlus avatar BoonPlus commented on July 30, 2024

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

image

from apex-mdapi.

afawcett avatar afawcett commented on July 30, 2024

That is very very cool!

from apex-mdapi.

afawcett avatar afawcett commented on July 30, 2024

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.

BoonPlus avatar BoonPlus commented on July 30, 2024

@afawcett my twitter account is @BoonPlus, feel free to share this with your followers. Cheers!

from apex-mdapi.

cnaccio avatar cnaccio commented on July 30, 2024

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

BoonPlus avatar BoonPlus commented on July 30, 2024

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.