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
jishan royjishan roy 

update contact record in account record page in lwc

hello,
can you please me out of this 

html:
<template>
    <table class="slds-table slds-table_cell-buffer slds-table_bordered">
        <template if:true={record}>
        <tr>
            <td><b>FirstName</b></td>
            <td><b>LastName</b></td>
            <td><b>Phone</b></td>
        </tr>
        <template for:each={record} for:item="acc">
            <tr key={acc.Id}>
                <td>
                    {acc.FirstName}
                </td>
                <td>
                    {acc.LastName}
                </td>
                <td>
                    {acc.Phone}
                </td>
               
            </tr>
        </template>
        </template>
    </table>
    <lightning-button
            class="slds-m-top_small"
            variant="brand"
            type="submit"
            name="update"
            label="Update"
        >
        </lightning-button>
</template>

js:

import { LightningElement,api,wire,track } from 'lwc';
import getContacts from '@salesforce/apex/contactController.getContacts';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { refreshApex } from '@salesforce/apex';
import { updateRecord } from 'lightning/uiRecordApi';
import FIRST_NAME_FIELD from '@salesforce/schema/Contact.FirstName';
import LAST_NAME_FIELD from '@salesforce/schema/Contact.LastName';
import ID_FIELD from '@salesforce/schema/Contact.Id';
import PHONE_FIELD from '@salesforce/schema/Contact.Phone';
export default class contactAccountInfo extends LightningElement {
  @api recordId;
  @track record;
  @track error;
 
  fields = [LAST_NAME_FIELD,FIRST_NAME_FIELD, ID_FIELD,PHONE_FIELD];
  @wire(getContacts, { accId: '$recordId' })
  cons({error,data}){
    console.log('recordId',this.recordId);
    if (data) {
        console.log('>>>data: ' + JSON.stringify(data));
        this.record = data;
        this.error = undefined;
        console.log('recordId',this.record);
    } else if (error) {
        this.error = error;
        this.data = undefined;
    }
}
handleSubmit(event) {
    console.log('onsubmit event recordEditForm'+ event.detail.fields);
}
handleSuccess(event) {
    console.log('onsuccess event recordEditForm', event.detail.id);
}
updateContact(event){
    this.contactId = event.target.dataset.recordid;
     const recordInput = {
         fields: {
             [Id.fieldApiName]: this.contactId,
             [contactFirstName.fieldApiName]: this.firstName,
             [contactLastName.fieldApiName]: this.lastName,
             [contactPhone.fieldApiName]: this.phone,
         }
     };
     updateRecord(recordInput).then((resolve) => {
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Success',
                message: 'Record Updated',
                variant: 'success',
            }),
        );
        return refreshApex(this.wiredContactsResult);
    }, (reason) => {
        console.log("Reason-->",reason);
    })
    //Show error when record does not updated
    .catch(error => {
      console.log("Error:--->  ",error);
    });
  }
 
}this is the table but that is not update how to do update help me outhow i can update multiple record at a time?
SwethaSwetha (Salesforce Developers) 
HI Jishan,
Does https://www.srinivas4sfdc.com/2019/12/how-to-select-and-update-multiple.html help?
mukesh guptamukesh gupta
Hi Jishan,

Please follow standard salesforce libirary :-

https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.data_table_inline_edit

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 
jishan royjishan roy
hii mukesh gupta,
not inline editing it will be on regarding my code which i sent.