function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bindhyachal Kumar SinghBindhyachal Kumar Singh 

Can we create Page Layout using MetaData API in salesforce Using java.

Hi All,

 

Can we create Pagelayout using MetadataAPI in salesforce using java. If yes then please give me some sample of code.

 

i have tried following code but it does not work.

LayoutItem li = new LayoutItem();
           	li.setField(uniqueobjectName+"."+uniqueField);
           	li.setHeight(100);
           	li.setWidth("30");           	
           	
           	LayoutColumn lc = new LayoutColumn();
           	lc.setLayoutItems(new LayoutItem[] {li});
        	
           	LayoutSection ls = new LayoutSection();
            ls.setCustomLabel(true);
            ls.setLabel("ABC");
            ls.setDetailHeading(true);
            ls.setLayoutColumns(new LayoutColumn[] {lc});
           	
            Layout lay = new Layout();
           	lay.setEmailDefault(true);
           	lay.setFullName("Report_Object_2__c-Bindhyachal");
           	lay.setLayoutSections(new LayoutSection[] {ls});
         	
           	AsyncResult[] asyncResults1 = metadataConnection.create(new Layout[] {lay});