Giter Site home page Giter Site logo

Comments (8)

afawcett avatar afawcett commented on July 30, 2024

Did you specify the correct Layout name? In my example I had a Custom Object called Test__c with a standard Layout. Unless you also have a Test__c object you will need to change this.

from apex-mdapi.

afawcett avatar afawcett commented on July 30, 2024

There does look to be a bug in the readMetadata method when you don't give a valid metadata component name, such as the correct layout, it does not throw an exception. But instead returns an empty Layout, thus when you later call the updateMetadata method it rejects it because the fullName is empty. The solution to this in the meantime is to always make sure you pass a valid component name to the readMetadata method.

from apex-mdapi.

mahesh10811f0011 avatar mahesh10811f0011 commented on July 30, 2024

Hi Andrew,
In another page i created Object name(Test) and fields name(TestField__c),one button and added like below and i added this code related methods also
public static void addFiedstolayout()
{
MetadataService.MetadataPort service = createService();
MetadataService.Layout layout =
(MetadataService.Layout) service.readMetadata('Layout',
new String[] { 'Test__c-Test Layout' }).getRecords()[0];
if(layout.layoutSections==null)
layout.layoutSections = new List<MetadataService.LayoutSection>();
MetadataService.LayoutSection newLayoutSection = new MetadataService.LayoutSection();
newLayoutSection.style = 'OneColumn';
System.debug('###newLayoutSection.style##########'+newLayoutSection.style);
MetadataService.LayoutColumn newLayoutColumn = new MetadataService.LayoutColumn();
MetadataService.LayoutItem newLayoutItem = new MetadataService.LayoutItem();
newLayoutItem.field = 'TestField__c';
System.debug('###newLayoutItem.field##########'+newLayoutItem.field);
newLayoutColumn.layoutItems = new List<MetadataService.LayoutItem> { newLayoutItem };
newLayoutSection.layoutColumns = new List<MetadataService.LayoutColumn> { newLayoutColumn };
layout.layoutSections.add(newLayoutSection);
handleSaveResults(
service.updateMetadata(
new MetadataService.Metadata[] { layout })[0]);
}
I got following error
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: null: Required field is missing: fullName faultcode=sf:UNKNOWN_EXCEPTION faultactor=
Error is in expression '{!addFiedstolayout}' in component apex:commandButton in page rajesh:createafieldusingmetadataapi

Class.rajesh.MetadataService.MetadataPort.updateMetadata: line 8163, column 1
Class.rajesh.MetadataController.addFiedstolayout: line 33, column 1
33 line:handleSaveResults(
service.updateMetadata(
new MetadataService.Metadata[] { layout })[0]);

IN DEBUGLOG LAYOUT Location like below
DEBUG|###layout##########Layout:[Metadata.apex_schema_type_info=(http://soap.sforce.com/2006/04/metadata, true, false), Metadata.field_order_type_info=(fullName), Metadata.fullName=null, Metadata.fullName_type_info=(fullName, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), apex_schema_type_info=(http://soap.sforce.com/2006/04/metadata, true, false), customButtons=null, customButtons_type_info=(customButtons, http://soap.sforce.com/2006/04/metadata, null, 0, -1, false), customConsoleComponents=null, customConsoleComponents_type_info=(customConsoleComponents, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), emailDefault=null, emailDefault_type_info=(emailDefault, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), excludeButtons=null, excludeButtons_type_info=(excludeButtons, http://soap.sforce.com/2006/04/metadata, null, 0, -1, false), feedLayout=null, feedLayout_type_info=(feedLayout, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), field_order_type_info=(fullName, customButtons, customConsoleComponents, emailDefault, excludeButtons, feedLayout, headers, layoutSections, miniLayout, multilineLayoutFields, ...), fullName=null, fullName_type_info=(fullName, http://www.w3.org/2001/XMLSchema, string, 0, 1, false), headers=null, headers_type_info=(headers, http://soap.sforce.com/2006/04/metadata, null, 0, -1, false), layoutSections=null, layoutSections_type_info=(layoutSections, http://soap.sforce.com/2006/04/metadata, null, 0, -1, false), miniLayout=null, miniLayout_type_info=(miniLayout, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), multilineLayoutFields=null, multilineLayoutFields_type_info=(multilineLayoutFields, http://soap.sforce.com/2006/04/metadata, null, 0, -1, false), quickActionList=null, quickActionList_type_info=(quickActionList, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), relatedContent=null, relatedContent_type_info=(relatedContent, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), relatedLists=null, relatedLists_type_info=(relatedLists, http://soap.sforce.com/2006/04/metadata, null, 0, -1, false), relatedObjects=null, relatedObjects_type_info=(relatedObjects, http://soap.sforce.com/2006/04/metadata, null, 0, -1, false), runAssignmentRulesDefault=null, runAssignmentRulesDefault_type_info=(runAssignmentRulesDefault, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), showEmailCheckbox=null, showEmailCheckbox_type_info=(showEmailCheckbox, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), showHighlightsPanel=null, showHighlightsPanel_type_info=(showHighlightsPanel, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), showInteractionLogPanel=null, showInteractionLogPanel_type_info=(showInteractionLogPanel, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), showKnowledgeComponent=null, showKnowledgeComponent_type_info=(showKnowledgeComponent, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), showRunAssignmentRulesCheckbox=null, showRunAssignmentRulesCheckbox_type_info=(showRunAssignmentRulesCheckbox, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), showSolutionSection=null, showSolutionSection_type_info=(showSolutionSection, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), showSubmitAndAttachButton=null, showSubmitAndAttachButton_type_info=(showSubmitAndAttachButton, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), summaryLayout=null, summaryLayout_type_info=(summaryLayout, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), type=Layout, type_att_info=(xsi:type)]

from apex-mdapi.

afawcett avatar afawcett commented on July 30, 2024

I still think 'Test__c-Test Layout' is wrong this is why your getting this problem. Can you use Developer Workbench to list the layouts and confirm the full name is 'Test__c-Test Layout'. Also are you developing in a packaging org with the namespace set? This can change the name of the layout.

from apex-mdapi.

mahesh10811f0011 avatar mahesh10811f0011 commented on July 30, 2024

Hi Andrew fawcett,
Here my object related Layout Information
Test__c-Test Layout:(full Name)

createdById: 005900000028CF8AAM
createdByName: rajesh
createdDate: 2014-07-10T05:18:43.000Z
fileName: layouts/Test__c-Test Layout.layout
fullName: Test__c-Test Layout
id: 00h9000000OMWm3AAH
lastModifiedById: 005900000028CF8AAM
lastModifiedByName: rajesh
lastModifiedDate: 2014-07-10T05:18:43.000Z
manageableState: unmanaged
namespacePrefix: rajesh
type: Layout

from apex-mdapi.

afawcett avatar afawcett commented on July 30, 2024

So your in a namespace org by the looks of this? Your namespace is set to rajesh under the Create > Packages page, is this correct?

If so, i think the full name needs to include the namespace, take a look at this issue #32. Especially this last comment...

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

Maybe you need to provide...

Test__c-rajesh__Test Layout   

Or try...

rajest__Test__c-rajesh__Test Layout   

from apex-mdapi.

mahesh10811f0011 avatar mahesh10811f0011 commented on July 30, 2024

Hi Andrew Fawcett,
That is Andrew Fawcett
Super Sir.................

from apex-mdapi.

afawcett avatar afawcett commented on July 30, 2024

Welcome! 👍

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.