You need to sign in to do that
Don't have an account?
Ashritha S
Problem while creating page layout using metadata api
Hi ,
I tried creating page layout using metadata api using the code
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
MetadataService.Layout layout = new MetadataService.Layout();
layout.fullName = 'Case-My Layout';
layout.layoutSections = new List<MetadataService.LayoutSection>();
MetadataService.LayoutSection layoutSection = new MetadataService.LayoutSection();
layoutSection.editHeading = true;
layoutSection.label = 'Description Information';
layoutSection.style = 'TwoColumnsTopToBottom';
layoutSection.layoutColumns = new List<MetadataService.LayoutColumn>();
MetadataService.LayoutColumn layoutColumn = new MetadataService.LayoutColumn();
layoutColumn.layoutItems = new List<MetadataService.LayoutItem>();
MetadataService.LayoutItem layoutItem1 = new MetadataService.LayoutItem();
layoutItem1.behavior = 'Required';
layoutItem1.field = 'Contact';
layoutColumn.layoutItems.add(layoutItem1);
layoutSection.layoutColumns.add(layoutColumn);
layout.layoutSections.add(layoutSection);
List<MetadataService.SaveResult> results =
service.createMetadata(
new MetadataService.Metadata[] { layout });
System.debug(results[0].errors[0].message);
I get the error message as USER_DEBUG [106]|DEBUG|Layout must contain an item for required layout field: ContactId .
I would be grateful if someone could help me solve this issue.
Thanks
I tried creating page layout using metadata api using the code
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
MetadataService.Layout layout = new MetadataService.Layout();
layout.fullName = 'Case-My Layout';
layout.layoutSections = new List<MetadataService.LayoutSection>();
MetadataService.LayoutSection layoutSection = new MetadataService.LayoutSection();
layoutSection.editHeading = true;
layoutSection.label = 'Description Information';
layoutSection.style = 'TwoColumnsTopToBottom';
layoutSection.layoutColumns = new List<MetadataService.LayoutColumn>();
MetadataService.LayoutColumn layoutColumn = new MetadataService.LayoutColumn();
layoutColumn.layoutItems = new List<MetadataService.LayoutItem>();
MetadataService.LayoutItem layoutItem1 = new MetadataService.LayoutItem();
layoutItem1.behavior = 'Required';
layoutItem1.field = 'Contact';
layoutColumn.layoutItems.add(layoutItem1);
layoutSection.layoutColumns.add(layoutColumn);
layout.layoutSections.add(layoutSection);
List<MetadataService.SaveResult> results =
service.createMetadata(
new MetadataService.Metadata[] { layout });
System.debug(results[0].errors[0].message);
I get the error message as USER_DEBUG [106]|DEBUG|Layout must contain an item for required layout field: ContactId .
I would be grateful if someone could help me solve this issue.
Thanks
While creating and saving a layout must include field Contact Name in that layout.
Regards,
Naveen