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 anyone suggest on how to read the flexipage? #301

Open
yogee-areya opened this issue Jan 18, 2024 · 7 comments
Open

Can anyone suggest on how to read the flexipage? #301

yogee-areya opened this issue Jan 18, 2024 · 7 comments

Comments

@yogee-areya
Copy link

No description provided.

@awalia123
Copy link

Can you please provide clarity on what you are trying to do? and the code base?

@paulliu-github
Copy link

paulliu-github commented Feb 12, 2024

@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> queries = new List<MetadataService.ListMetadataQuery>();
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);
}
}

@yogee-areya
Copy link
Author

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

@jaelee125
Copy link

@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

@paulliu-github
Copy link

@jaelee125 try this...
system.debug('flexipage = ' + flexipage.flexiPageRegions[0].iteminstances[0]);

@jaelee125
Copy link

@paulliu-github That line errors out because flexipage.flexiPageRegions is null

@paulliu-github
Copy link

@jaelee125 I don't know why it happened, have you tried to run the same code in a different org?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants