TransWikia.com

Edit the record page using Metadata API in LWC

Salesforce Asked on October 4, 2021

What

I want to edit a record page (Account rec page) with the respective value and update this record by using Salesforce Metadata API

So far

I am developing an LWC component where I can update the record page through metadata API without adding all the input fields (lightning-input-field) inside the template, instead of that can I iterate all the available fields present in that record page using Metadata API (ref: below code).

As I am dealing with the sObject I found some solution but with lack of explanations and how can I read and update the record for current pagelayout by using the metadata API

P.S:- any reference solution for this would be appreciated

<template for:each={fieldList} for:item='fieldName'>   
<lightning-input-field key={fieldName} field-name={fieldName} ></lightning-input-field>    
</template>

One Answer

I think there are several misconceptions here that are making your life more difficult than it needs to be. Starting from small things and going up,

  • Record Pages and Page Layouts are different metadata entities. Record Pages arrange components on the page in Lightning Experience. Page Layouts arrange fields on the page layout (Classic) and on the Record Details component (Lightning).
  • Neither Record Pages nor Page Layouts are HTML (they are XML).
  • The Metadata API is for making changes to your org's setup and for moving metadata between your org and other locations, such as source control. It is not generally suitable for use in UI components for a variety of reasons, including that it is very slow.

Your objective is a little bit fuzzy to me but it sounds like your goal is to identify a set of fields on an object based on the Page Layout and represent them in your component. If that is accurate, you should consider using the UI API, which is intended to support developing custom user interfaces over Salesforce data, or possibly using Field Sets, which you can easily get information about in Apex through the Describe API and relay to your component.

Answered by David Reed on October 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP