Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't update manage package Page Layout #32

Closed
kbabintsev opened this issue Jun 17, 2014 · 9 comments

Comments

@kbabintsev
Copy link

commented Jun 17, 2014

Hi. I'm trying to update Layout:

    MetadataService.MetadataPort service = new MetadataService.MetadataPort();
    service.SessionHeader = new MetadataService.SessionHeader_element();
    service.SessionHeader.sessionId = sessionId;
    service.endpoint_x = endpoint;

    MetadataService.Layout layout = 
        (MetadataService.Layout)service.readMetadata('Layout', 
            new String[] { 'CaAwsCloudTrailEvent__c-AWS CloudTrail Event Layout' }).getRecords()[0];

    System.debug(layout.fullName);

    handleSaveResults(
        service.updateMetadata(
            new MetadataService.Metadata[] { layout })[0]);        

    System.debug('DONE');

but getting error "Required field is missing: fullName", because retrieved field fullName is null. It is possible update MP page layout through metadata api? Thank you.

@afawcett

This comment has been minimized.

Copy link
Contributor

commented Jun 17, 2014

Yes it is possible to do this https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataServiceExamples.cls#L696. What i have noticed is that for some reason if you get the layout name wrong it returns a blank layout. So double check your layout name via listMetadata or using the Salesforce Developer Workbench tool which also has a means to list metadata.

@kbabintsev

This comment has been minimized.

Copy link
Author

commented Jun 17, 2014

Yes, name was wrong. Valid name is 'CA10__CaAwsCloudTrailEvent__c-AWS CloudTrail Event Layout' (CA10 is our namespace). But I get the same error. I tried to do this with Java API v29 (http://www.salesforce.com/us/developer/docs/api_meta/), but I got the same result. Everything works well with dev org (where name is 'CaAwsCloudTrailEvent__c-AWS CloudTrail Event Layout').

@afawcett

This comment has been minimized.

Copy link
Contributor

commented Jun 17, 2014

I see so it works if you try to edit a unmanaged layout, but if you try to edit a managed package installed layout it fails? Is CA10 your managed package namespace?

@kbabintsev

This comment has been minimized.

Copy link
Author

commented Jun 17, 2014

Yes, that's right. Yes, "CA10" is our namespace.

@afawcett

This comment has been minimized.

Copy link
Contributor

commented Jun 17, 2014

I'm wondering if this is restriction of the Metadata API, have you tried API v30.0?

@kbabintsev

This comment has been minimized.

Copy link
Author

commented Jun 17, 2014

v29 is latest version available in maven central http://mvnrepository.com/artifact/com.force.api/force-metadata-api

@kbabintsev

This comment has been minimized.

Copy link
Author

commented Jun 18, 2014

I solved this. It works if I try 'CA10__CaAwsCloudTrailEvent__c-CA10__AWS CloudTrail Event Layout'. btw listMetadata returns 'CA10__CaAwsCloudTrailEvent__c-AWS CloudTrail Event Layout' (without prefix).

@afawcett

This comment has been minimized.

Copy link
Contributor

commented Jun 18, 2014

Wow that is inconsistant, glad you sorted it! Enjoy the API now! 👍

@adam84luong

This comment has been minimized.

Copy link

commented May 5, 2017

Thanks kbabintsev, your solution worked even in v39.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.