You need to sign in to do that
Don't have an account?
The new Learner
How to open a existing record with record edit form on button click
Hi Experts,
I need to create a button called Edit record, it will open the current record in edit view and the user can change details and save. can anyone help me, I have written below however it's not working for me.
I need to create a button called Edit record, it will open the current record in edit view and the user can change details and save. can anyone help me, I have written below however it's not working for me.
Template: <template> <template if:true={showRecScreen}> <lightning-record-edit-form object-api-name={objectApiName} record-id={recordId}> <lightning-input-field field-name={nameField}> </lightning-input-field> <div class="slds-var-m-top_medium"> <lightning-button variant="brand" type="submit" label="Save"> </lightning-button> </div> </lightning-record-edit-form> </template> <lightning-button name="Update" label="Updateedit" onclick={handleUpdate}></lightning-button> </template> JS: import { LightningElement,api } from 'lwc'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import NAME_FIELD from '@salesforce/schema/Account.Name'; export default class Editrecordeditformpage extends LightningElement { @api objectApiName = 'Account'; showRecScreen = false; nameField = NAME_FIELD; handleUpdate(){ this.showRecScreen = true; } handleSuccess(event) { const evt = new ShowToastEvent({ title: "Account created", message: "Record ID: " + event.detail.id, variant: "success" }); this.dispatchEvent(evt); } }