Open yogee-areya opened 10 months ago
@yogee-areya try the code below. If you would like to run the code in the latest API version, please read my article on LinkedIn.
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
service.timeout_x = 120000;
List
MetadataService.ListMetadataQuery queryFlexiPage = new MetadataService.ListMetadataQuery();
queryFlexiPage.type_x = 'FlexiPage';
queries.add(queryFlexiPage);
MetadataService.FileProperties[] fileProperties = service.listMetadata(queries, 42);
if (fileProperties != null) {
for (MetadataService.FileProperties fileProperty : fileProperties) {
String fullName = EncodingUtil.urlDecode(fileProperty.fullName,'UTF-8');
// Read the FlexiPage
MetadataService.FlexiPage flexipage = (MetadataService.FlexiPage) service.readMetadata('FlexiPage', new String[] { fullName }).getRecords()[0];
system.debug('fullName = ' + fullName);
}
}
@paulliu-github Thank you so much for this code piece. Now i'm able to read the Metadata of Flexipages and the blog post really helps.
@paulliu-github How can you go about getting all the component/item instances for the flexipage? It looks like the actual flexi page returned just has null value for flexiPageRegions
@jaelee125 try this... system.debug('flexipage = ' + flexipage.flexiPageRegions[0].iteminstances[0]);
@paulliu-github That line errors out because flexipage.flexiPageRegions is null
@jaelee125 I don't know why it happened, have you tried to run the same code in a different org?
Can you please provide clarity on what you are trying to do? and the code base?