• Abhishek Sharma 527
  • NEWBIE
  • 140 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 21
    Questions
  • 20
    Replies
Hello there, I accidentally added job application object to all the apps and saved it. How can edit it which will limit it to recruiting app only?
kindly help
Hello, I have LWC to show contact records and modal to edit the records, while editing record it shows error as fields are read-only, can anyone help.
// html

    <template>
        <lightning-card title="Contact Records">
       
            <lightning-datatable data={wireContact.data} columns={columns} key-field="id" hide-checkbox-column="true"  onrowaction={handleRowAction}  ></lightning-datatable>
           
            <template if:true={modalContainer}>
                <section  class="slds-modal slds-fade-in-open">
                    <div class="slds-modal__container">
                        <header class="slds-modal__header">
                            <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closeModalAction}>
                            <lightning-icon icon-name="utility:close" alternative-text="close" variant="inverse" size="small" ></lightning-icon>
                            </button>
                           
                            <h2 class="slds-text-heading_medium slds-hyphenate">Contact Record Detail</h2>
                        </header>
                        <div class="slds-modal__content slds-p-around_medium">
                            <table class="slds-table slds-table_bordered slds-table_col-bordered slds-table_cell-buffer">
                            <thead>
                                <tr>
                                    <th>First Name</th>
                                    <th>Last Name</th>
                                    <th>Email Name</th>
                                    <th>Phone Name</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>

                                    <td><lightning-input
                                        type="text"
                                        label="First name"
                                        value={contactRow.FirstName}
                                        onchange={handleChange}>
                                    </lightning-input></td>
                                    <td><lightning-input
                                        type="text"
                                        label="Last name"
                                        value={contactRow.LastName}
                                        onchange={handleChange}>
                                    </lightning-input></td>
                                    <td><lightning-input
                                        type="Email"
                                        label="Email"
                                        value={contactRow.Email}
                                        onchange={handleChange}>
                                    </lightning-input></td>
                                    <td><lightning-input
                                        type="tel"
                                        label="Phone"
                                        value={contactRow.Phone}
                                        onchange={handleChange}>
                                    </lightning-input> </td>
                                </tr>
                            </tbody>  
                            </table>
                        </div>
                        <footer class="slds-modal__footer">
                       
                            <lightning-button class="slds-p-horizontal_medium" id="btn1" variant="brand" label="Close" title="Close"  onclick={closeModalAction}></lightning-button>
                            <lightning-button class="slds-p-horizontal_medium" variant="brand" label="Save" title="Save" type="submit" onclick={handleSave}></lightning-button>
                       
                    </footer>
                    </div>
                </section>
                <div class="slds-backdrop slds-backdrop_open"></div>
            </template>
        </lightning-card>
    </template>

----------------------------------------------

// JS code
import { LightningElement, track, wire } from 'lwc';
import getContacts from '@salesforce/apex/LWCExampleController.getContacts';
import saveRecords from '@salesforce/apex/LWCExampleController.saveRecords';
const columns=[
    {label: 'View',type: 'button-icon', initialWidth: 75, typeAttributes: { iconName: 'action:preview', title: 'Preview',
     variant: 'border-filled', alternativeText: 'View'}
      },
    { label: 'First Name',fieldName: 'FirstName', editable: true},
    { label: 'Last Name',   fieldName: 'LastName', editable: true},
    { label: 'Email', fieldName: 'Email'},
    { label: 'Phone',   fieldName: 'Phone'}
];
export default class LwcDataTableRowAction extends LightningElement {
  @track columns = columns;
  @track contactRow={};
  @track rowOffset = 0;  
  @track modalContainer = false;
  @track saveDraftValues = [];
  @track contacts;
   @wire(getContacts) wireContact;
 
   handleRowAction(event){
      const dataRow = event.detail.row;
      window.console.log('dataRow@@ ' + dataRow);
      this.contactRow=dataRow;
      window.console.log('contactRow## ' + dataRow);
      this.modalContainer=true;
   }
 
   handleChange(event){
      if(event.target.label=='First name'){
          this.contactRow.FirstName = event.target.value;
      }
      if(event.target.label=='Last name'){
          this.contactRow.LastName = event.target.value;
      }            
      if(event.target.label=='Email'){
          this.contactRow.Email = event.target.value;
      }
      if(event.target.label=='Phone'){
         this.contactRow.Phone = event.target.value;
     }
   }
   handleSave(){
      saveRecords({ contactToUpdate: this.contactRow })
           .then((result) => {
               console.log(result);
           })
           .catch((error) => {
               console.log(error);
           });
  }
   closeModalAction(){
    this.modalContainer=false;
   }
}

-------------------------------------------------------
// apex class

public inherited sharing class LWCExampleController {
    @AuraEnabled(Cacheable = true)
    public static List<Contact> getContacts() {
        return [SELECT Id, Name, FirstName, LastName, Phone, Email
                FROM Contact
                WHERE Email != null
                AND Phone != null
                ORDER BY CreatedDate DESC NULLS LAST limit 10];
    }
    @AuraEnabled
   public static void saveRecords(Contact contactsToUpdate){
   
    update contactsToUpdate;
   }
}
Hello there, I have LWC to show contact records and modal to edit the records, I'm able to fetch records and editing also showing but don't know how to write apex class and call into JS, please anyone guide, it will be great help.

//html 
  <!-- <template>
    <c-record_modal></c-record_modal>
    <lightning-card title="Contact Records" style="font-size: 10px">
        <template if:true={contacts.data}>
            <lightning-datatable key-field="Id"
                                 data={contacts.data}
                                 columns={columns}
                                 onsave={handleSave}
                                 draft-values={saveDraftValues}
                                 hide-checkbox-column
                                 show-row-number-column>
                                </lightning-datatable>
        </template>
           
    </lightning-card>
</template> -->

<template>
    <lightning-card title="Contact Records">
       
        <lightning-datatable data={wireContact.data} columns={columns} key-field="id" hide-checkbox-column="true"  onrowaction={handleRowAction}></lightning-datatable>
       
        <template if:true={modalContainer}>
            <section  class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <header class="slds-modal__header">
                        <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closeModalAction}>
                           <lightning-icon icon-name="utility:close" alternative-text="close" variant="inverse" size="small" ></lightning-icon>
                        </button>
                       
                        <h2 class="slds-text-heading_medium slds-hyphenate">Contact Record Detail</h2>
                     </header>
                     <div class="slds-modal__content slds-p-around_medium">
                        <table class="slds-table slds-table_bordered slds-table_col-bordered slds-table_cell-buffer">
                           <thead>
                            <tr>
                                <th>First Name</th>
                                <th>Last Name</th>
                                <th>Email Name</th>
                                <th>Phone Name</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>

                                <td><lightning-input
                                    type="text"
                                    label="first name"
                                    value={contactRow.FirstName}>
                                </lightning-input></td>
                                <td><lightning-input
                                    type="text"
                                    label="Last name"
                                    value={contactRow.LastName}>
                                </lightning-input></td>
                                <td><lightning-input
                                    type="Email"
                                    label="Email"
                                    value={contactRow.Email}>
                                </lightning-input></td>
                                <td><lightning-input
                                    type="tel"
                                    label="Phone"
                                    value={contactRow.Phone}>
                                </lightning-input> </td>
                            </tr>
                        </tbody>  
                        </table>
                     </div>
                     <footer class="slds-modal__footer">
                     
                        <lightning-button class="slds-p-horizontal_medium" id="btn1" variant="brand" label="Close" title="Close"  onclick={closeModalAction}></lightning-button>
                        <lightning-button class="slds-p-horizontal_medium" variant="brand" label="Save" title="Save"  onclick={handleSave}></lightning-button>
                       
                   </footer>
                </div>
            </section>
            <div class="slds-backdrop slds-backdrop_open"></div>
        </template>
    </lightning-card>
</template>

--------------------------------------------------------------------------

//JS code

import { LightningElement, track, wire } from 'lwc';
import getContacts from '@salesforce/apex/LWCExampleController.getContacts';
const columns=[
    {
        label: 'View',
        type: 'button-icon',
        initialWidth: 75,
        typeAttributes: {
            iconName: 'action:preview',
            title: 'Preview',
            variant: 'border-filled',
            alternativeText: 'View'
        }
      },
      {
        label: 'First Name',
        fieldName: 'FirstName'
    },
    {
        label: 'Last Name',
        fieldName: 'LastName'
    },
    {
        label: 'Email',
        fieldName: 'Email'
    },
    {
        label: 'Phone',
        fieldName: 'Phone'
    }
];
export default class LwcDataTableRowAction extends LightningElement {
  @track columns = columns;
  @track contactRow={};
  @track rowOffset = 0;  
  @track modalContainer = false;
   @wire(getContacts) wireContact;
 
   handleRowAction(event){
      const dataRow = event.detail.row;
      window.console.log('dataRow@@ ' + dataRow);
      this.contactRow=dataRow;
      window.console.log('contactRow## ' + dataRow);
      this.modalContainer=true;
   }
handleSave(){
    saveRecords(this.contactRow)
   }
   closeModalAction(){
    this.modalContainer=false;
   }
}

----------------------------------------------------------------

// class file

public inherited sharing class LWCExampleController {
    @AuraEnabled(Cacheable = true)
    public static List<Contact> getContacts() {
        return [SELECT Id, Name, FirstName, LastName, Phone, Email
                FROM Contact
                WHERE Email != null
                AND Phone != null
                ORDER BY CreatedDate DESC NULLS LAST limit 10];
    }
     @AuraEnabled(Cacheable = true)
   public static void saveRecords(List <Contact> contactsToUpdate){

contactsToUpdate = [Select FirstName, LastName, Phone, Email FROM Contact];

      update contactsToUpdate; 
   }
}
Hello there, I have LWC to show contact records and modal to edit the records, I'm able to fetch records and editing also showing but don't know how to run query to update records, pls look into my code and suggest.

//html 
  <!-- <template>
    <c-record_modal></c-record_modal>
    <lightning-card title="Contact Records" style="font-size: 10px">
        <template if:true={contacts.data}>
            <lightning-datatable key-field="Id"
                                 data={contacts.data}
                                 columns={columns}
                                 onsave={handleSave}
                                 draft-values={saveDraftValues}
                                 hide-checkbox-column
                                 show-row-number-column>
                                </lightning-datatable>
        </template>
           
    </lightning-card>
</template> -->

<template>
    <lightning-card title="Contact Records">
       
        <lightning-datatable data={wireContact.data} columns={columns} key-field="id" hide-checkbox-column="true"  onrowaction={handleRowAction}></lightning-datatable>
       
        <template if:true={modalContainer}>
            <section  class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <header class="slds-modal__header">
                        <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closeModalAction}>
                           <lightning-icon icon-name="utility:close" alternative-text="close" variant="inverse" size="small" ></lightning-icon>
                        </button>
                       
                        <h2 class="slds-text-heading_medium slds-hyphenate">Contact Record Detail</h2>
                     </header>
                     <div class="slds-modal__content slds-p-around_medium">
                        <table class="slds-table slds-table_bordered slds-table_col-bordered slds-table_cell-buffer">
                           <thead>
                            <tr>
                                <th>First Name</th>
                                <th>Last Name</th>
                                <th>Email Name</th>
                                <th>Phone Name</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>

                                <td><lightning-input
                                    type="text"
                                    label="first name"
                                    value={contactRow.FirstName}>
                                </lightning-input></td>
                                <td><lightning-input
                                    type="text"
                                    label="Last name"
                                    value={contactRow.LastName}>
                                </lightning-input></td>
                                <td><lightning-input
                                    type="Email"
                                    label="Email"
                                    value={contactRow.Email}>
                                </lightning-input></td>
                                <td><lightning-input
                                    type="tel"
                                    label="Phone"
                                    value={contactRow.Phone}>
                                </lightning-input> </td>
                            </tr>
                        </tbody>  
                        </table>
                     </div>
                     <footer class="slds-modal__footer">
                     
                        <lightning-button class="slds-p-horizontal_medium" id="btn1" variant="brand" label="Close" title="Close"  onclick={closeModalAction}></lightning-button>
                        <lightning-button class="slds-p-horizontal_medium" variant="brand" label="Save" title="Save"  onclick={handleSave}></lightning-button>
                       
                   </footer>
                </div>
            </section>
            <div class="slds-backdrop slds-backdrop_open"></div>
        </template>
    </lightning-card>
</template>

--------------------------------------------------------------------------

//JS code

import { LightningElement, track, wire } from 'lwc';
import getContacts from '@salesforce/apex/LWCExampleController.getContacts';
const columns=[
    {
        label: 'View',
        type: 'button-icon',
        initialWidth: 75,
        typeAttributes: {
            iconName: 'action:preview',
            title: 'Preview',
            variant: 'border-filled',
            alternativeText: 'View'
        }
      },
      {
        label: 'First Name',
        fieldName: 'FirstName'
    },
    {
        label: 'Last Name',
        fieldName: 'LastName'
    },
    {
        label: 'Email',
        fieldName: 'Email'
    },
    {
        label: 'Phone',
        fieldName: 'Phone'
    }
];
export default class LwcDataTableRowAction extends LightningElement {
  @track columns = columns;
  @track contactRow={};
  @track rowOffset = 0;  
  @track modalContainer = false;
   @wire(getContacts) wireContact;
 
   handleRowAction(event){
      const dataRow = event.detail.row;
      window.console.log('dataRow@@ ' + dataRow);
      this.contactRow=dataRow;
      window.console.log('contactRow## ' + dataRow);
      this.modalContainer=true;
   }
//    handleSave(){
//     saveRecords()
//    }
   closeModalAction(){
    this.modalContainer=false;
   }
}

----------------------------------------------------------------

// class file

public inherited sharing class LWCExampleController {
    @AuraEnabled(Cacheable = true)
    public static List<Contact> getContacts() {
        return [SELECT Id, Name, FirstName, LastName, Phone, Email
                FROM Contact
                WHERE Email != null
                AND Phone != null
                ORDER BY CreatedDate DESC NULLS LAST limit 10];
    }
    // @AuraEnabled(Cacheable = true)
    // public static List<Contact> saveRecords(){
    //     return [UPDATE FirstName, LastName, Phone, Email FROM Contact] //clarification on this
    // }
}
 
Hello There, I have lwc app which shows contact records and I can edit it also but my requirement is it should be editable in modal. my code has modal functionality as well but both functionalities working seperately, I need it should be editable in modal.
I know some lines of code (code to edit records )need to be placed inside modal but It's not happening, can anyone pls look into my code.

// html

<template>
    <lightning-card title="Contact details">
       
        <lightning-datatable data={wireContact.data} columns={columns} key-field="id"   onrowaction={handleRowAction} onsave={handleSave}></lightning-datatable>
       
        <template if:true={modalContainer}>
            <section  class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <header class="slds-modal__header">
                       
                        <h2 class="slds-text-heading_medium slds-hyphenate">Contact Record Detail</h2>
                     </header>
                     <div class="slds-modal__content slds-p-around_medium">
                        <table class="slds-table slds-table_bordered slds-table_col-bordered slds-table_cell-buffer">
                           <thead>
                            <tr>
                                <th>First Name</th>
                                <th>Last Name</th>
                                <th>Email Name</th>
                                <th>Phone Name</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>{contactRow.FirstName}</td>
                                <td>{contactRow.LastName}</td>
                                <td>{contactRow.Email}</td>
                                <td>{contactRow.Phone}</td>
                            </tr>
                        </tbody>  
                        </table>
                     </div>
                     <footer class="slds-modal__footer">
                        <lightning-button variant="brand" label="Close" title="Close"  onclick={closeModalAction}></lightning-button>
                        <lightning-button variant="brand" label="Save" title="Close"  onclick={handleSave}></lightning-button>
                   </footer>
                </div>
            </section>
            <div class="slds-backdrop slds-backdrop_open"></div>
        </template>
        <br/><br/>
   
    </lightning-card>
</template>


--------------------------------------------------
//js code

import { LightningElement, track, wire } from 'lwc';
import getDataFromContact from '@salesforce/apex/LWCExampleController.getDataFromContact';
const columns=[
    {
        label: 'View',
        type: 'button-icon',
        initialWidth: 75,
        typeAttributes: {
            iconName: 'action:preview',
            title: 'Preview',
            variant: 'border-filled',
            alternativeText: 'View'
        }
      },
      {
        label: 'First Name',
        fieldName: 'FirstName'
    },
    {
        label: 'Last Name',
        fieldName: 'LastName'
    },
    {
        label: 'Email',
        fieldName: 'Email'
    },
    {
        label: 'Phone',
        fieldName: 'Phone'
    }
];
export default class LwcDataTableRowAction extends LightningElement {
  @track columns = columns;
  @track contactRow={};
  @track rowOffset = 0;  
  @track modalContainer = false;
   @wire(getDataFromContact) wireContact;
 
   handleRowAction(event){
      const dataRow = event.detail.row;
      window.console.log('dataRow@@ ' + dataRow);
      this.contactRow=dataRow;
      window.console.log('contactRow## ' + dataRow);
      this.modalContainer=true;
   }
   closeModalAction(){
    this.modalContainer=false;
   }
   handleSave(event) {
    this.saveDraftValues = event.detail.draftValues;
    const recordInputs = this.saveDraftValues.slice().map(draft => {
        const fields = Object.assign({}, draft);
        return { fields };
    });
    // Updateing the records using the UiRecordAPi
    const promises = recordInputs.map(recordInput => updateRecord(recordInput));
    Promise.all(promises).then(res => {
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Success',
                message: 'Records Updated Successfully!!',
                variant: 'success'
            })
        );
        this.saveDraftValues = [];
        return this.refresh();
    }).catch(error => {
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Error',
                message: 'An Error Occured!!',
                variant: 'error'
            })
        );
    }).finally(() => {
        this.saveDraftValues = [];
    });
}
}

-------------------------------------------------------
// class code

public with sharing class LWCExampleController {
 
    // Create a lightning-datatable and display modal on rowaction
    @AuraEnabled(cacheable=true)
    public static List<Contact> getDataFromContact(){
      List<Contact> conList = [Select Id, FirstName, LastName, Email, Phone From Contact limit 10];
      try{
         return conList;
      }
      catch(Exception e){
         throw new AuraHandledException(e.getMessage());
      }
    }
}

---------------------------------------------------------------
Hello There, I have LWC app which works to show records and edit it in same page, I need to add modal popup which should be visible whenever I try to edit the record
can anyone help in this.

//html code
<template>
    <lightning-card title="Inline Edit With Lightning Datatable in LWC">
        <template if:true={contacts.data}>
            <lightning-datatable key-field="Id"
                                 data={contacts.data}
                                 columns={columns}
                                 onsave={handleSave}
                                 draft-values={saveDraftValues} >
            </lightning-datatable>
        </template>
    </lightning-card>
</template>

//js code
import { LightningElement, track, wire } from 'lwc';
import getContacts from '@salesforce/apex/LWCExampleController.getContacts';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { refreshApex } from '@salesforce/apex';
// datatable columns
const columns = [
    {
        label: 'Name',
        fieldName: 'Name',
        type: 'text',
    }, {
        label: 'FirstName',
        fieldName: 'FirstName',
        type: 'text',
        editable: true,
    }, {
        label: 'LastName',
        fieldName: 'LastName',
        type: 'text',
        editable: true,
    }, {
        label: 'Phone',
        fieldName: 'Phone',
        type: 'phone',
        editable: true
    }
];
export default class popup extends LightningElement {
   
    columns = columns;
    @track contacts;
    saveDraftValues = [];
    @wire(getContacts)
    cons(result) {
        this.contacts = result;
        if (result.error) {
            this.contacts = undefined;
        }
    };
    handleSave(event) {
        this.saveDraftValues = event.detail.draftValues;
        const recordInputs = this.saveDraftValues.slice().map(draft => {
            const fields = Object.assign({}, draft);
            return { fields };
        });
        // Updateing the records using the UiRecordAPi
        const promises = recordInputs.map(recordInput => updateRecord(recordInput));
        Promise.all(promises).then(res => {
            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Success',
                    message: 'Records Updated Successfully!!',
                    variant: 'success'
                })
            );
            this.saveDraftValues = [];
            return this.refresh();
        }).catch(error => {
            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Error',
                    message: 'An Error Occured!!',
                    variant: 'error'
                })
            );
        }).finally(() => {
            this.saveDraftValues = [];
        });
    }
    // This function is used to refresh the table once data updated
    async refresh() {
        await refreshApex(this.contacts);
    }
}

// class file

public with sharing class LWCExampleController {
    @AuraEnabled(Cacheable = true)
    public static List<Contact> getContacts() {
        return [SELECT Id, Name, FirstName, LastName, Phone, Email
                FROM Contact
                WHERE Email != null
                AND Phone != null
                ORDER BY CreatedDate DESC NULLS LAST limit 10];
    }
}

 
Hello There, I have lwc which shows list of contact records and I added editable='true' in result page it's getting edit but not getting saved, I'm not sure where and how to query update query
Can anyone help me in writing code to save the updated record.

// html code
<template>
     <h2> Contact Datatable</h2>     
         <lightning-datatable data={wiredContacts.data} columns={columns} key-field="Id">
         </lightning-datatable>     
 </template>

// js code
import { LightningElement ,api, wire, track} from 'lwc';
import getContactList from '@salesforce/apex/method.getContactList';
export default class contactRecord extends LightningElement {
   
         @track columns = [
          { label: 'Name', fieldName: 'Name', editable: true},
          { label: 'Id', fieldName: 'Id'},
            {label: 'Email', fieldName: 'Email'}
      ];
      @track conList;
      @track error;
      @wire(getContactList)
      wiredContacts;
}

// class code
public with sharing class method {
    @AuraEnabled(cacheable=true)
    public static List<Contact> getContactList() {
        return [SELECT Id, Name, email
            FROM Contact];
    }
}
Hello there, I have created lwc for showing contact records but I want to show associated account name also but in result page it shows blank in account field
can anyone pls assist in this. my code as follows.
//html
<template>
     <h2> Contact Datatable</h2>
     <template if:true={conList}>
         <lightning-datatable data={conList} columns={columns} key-field="Id">
         </lightning-datatable>
     </template>
     <template if:true={error}>
         {error}
     </template>
 </template>

//js code
import { LightningElement ,api, wire, track} from 'lwc';
import getContactList from '@salesforce/apex/method.getContactList';
export default class contactRecord extends LightningElement {
   
         @track columns = [
          { label: 'Name', fieldName: 'Name' },
          { label: 'Id', fieldName: 'Id'},
            {label: 'Account', fieldName: 'Account.Name'},
            {label: 'Email', fieldName: 'Email'}
      ];
    @track conList;
    @track error;
    @wire(getContactList)
    wiredContacts({
        error,
        data
    }) {
        if (data) {
            this.conList = data;
        } else if (error) {
            this.error = error;
        }
    }
}
------------------------
// class code
public with sharing class method {
    @AuraEnabled(cacheable=true)
    public static List<Contact> getContactList() {
        return [SELECT Id, Name, Account.Name, email
            FROM Contact];
    }
}
--------------------------------------------------------
Hello there, I have created lwc application to show contact records, I'm able to fetch records and print in on console but it doesn't load result in app page and lightning page, it shows blank page.
can anyone pls assist in this, here's my code.

//html code
<template>
    <template for:each={wiredAccounts.data} for:item="acc">
         <p key={acc.id}>
              {acc.Name}
         </p>
    </template>
</template>

------------------------------------
// js code
import { LightningElement, wire, track } from 'lwc';
import displayCon from '@salesforce/apex/method.displayCon';
export default class ContactRecord extends LightningElement {

    @wire (displayCon) wiredAccounts({data,error}){
        if (data) {
        console.log(data);
        } else if (error) {
        console.log(error);
        }
   }
}
-----------------------------------------------
// class code
public with sharing class method {
    @AuraEnabled(cacheable=true)
   public static List<Contact> displayCon(){
    List<Contact> con;
    try {
        con = [Select Id, Name, Phone, email From Contact LIMIT 20];
    } catch (Exception e) {
        System.debug(e.getMessage());
    }
        return con;
   }
}
----------------------------------------------
//xml file

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>55.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
    </targets>
</LightningComponentBundle>

---------------------------------------
// app code

<aura:application extends="force:slds">
<c:contactRecord/>
</aura:application>
 
Hello Folks, I have created Visualforce page which shows records of account and it's editable also there's checkbox but now requirement is to make records editable only when checkbox is checked, for example if i check 3 checkbox out of 10 records then only those 3 should be editable.

can anyone help in fufilling this requirement.

//my VF code 

<apex:page standardController="account" sidebar="false" recordSetVar="records">
    
    <apex:form>
        <apex:pageBlock>
        <apex:pageBlockTable value="{!records}" var="rec">
            <apex:column headervalue="checkbox">
                <apex:inputCheckbox/>
            </apex:column>
            <apex:column>
                <apex:outputField label="name" value="{!rec.name}"/>
                <apex:facet name="header">Account name</apex:facet>
            </apex:column>
            <apex:column>
                <apex:outputField label="industry" value="{!rec.industry}"/>
            <apex:facet name="header">Industry</apex:facet>
            </apex:column>
            
            <apex:inlineEditSupport event="ondblclick"/>
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="Bottom">
            <apex:commandButton value="Save" action="{!save}" id="saveButton"/>
                <apex:commandButton value="Edit" action="{!save}" id="editButton"/>
                <apex:commandButton value="Cancel" action="{!cancel}" id="delButton"/>
                </apex:pageBlockButtons>
            
             </apex:pageBlock>
    </apex:form>
</apex:page>

 
Hello There, I have created visualforce page which returns account records, I need checkbox in the result page along with records, can anyone plz guide how i can achieve that.
User-added image

// my visualforce code

<apex:page controller="Demo2VF_Class">
<apex:form >
    <apex:pageBlock title="Account information">
        <apex:pageBlockTable value="{!acc}" var="item">
            <apex:column value="{!item.id}"/>
            <apex:column value="{!item.name}"/>
            <apex:column value="{!item.Type}"/>
            <apex:column value="{!item.rating}"/>
        
        </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>

//my class code
public class Demo2VF_Class {
    
    public List<Account> acc{get;set;}
    
    public Demo2VF_Class(){
        acc = [Select id, name, Type, Account.Rating from Account];
      
        
    }
}
Hello There, I have created visualforce page which returns account records, I need checkbox in the result page, can anyone plz guide how i can achieve that.

// my visualforce code

<apex:page controller="Demo2VF_Class">
<apex:form >
    <apex:pageBlock title="Account information">
        <apex:pageBlockTable value="{!acc}" var="item">
            <apex:column value="{!item.id}"/>
            <apex:column value="{!item.name}"/>
            <apex:column value="{!item.Type}"/>
            <apex:column value="{!item.rating}"/>
        
        </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>

//my class code
public class Demo2VF_Class {
    
    public List<Account> acc{get;set;}
    
    public Demo2VF_Class(){
        acc = [Select id, name, Type, Account.Rating from Account];
      
        
    }
}
Hello There, I have custom roll up summary handler class and trigger created seperately, I'm not aware about testing and don't know whether it will be written for handler class or trigger program. 

also can anyone help in adding test case for this insertMethod (I have 2 other method, for which I will implement with that reference )

//handler class
public class Contact_count_Handler 
{     
    public static void InsertMethod(List<Contact> newList){
        List<Account> accList = new List<Account>();
        try{
        Set<id> accountIds = new Set<id>();        
        
        if(newList!=null) {
            
            for(contact c: newList)    
            {
                if(c.accountId!=null)            
                {
                    accountIds.add(c.accountId); 
                }
            }
           
            
            if(!accountIds.isEmpty()){
                for(Account acc :[Select id,Number_of_linked_contact__c,(Select id,name from contacts) from Account where Id in : accountIds]){
                    
                    acc.Number_of_linked_contact__c= acc.contacts.size();
                    
                    acclist.add(acc);
                }
                if(acclist.size()>0){
                    update accList; 
                }
            }
        }   
        
    }
         catch(Exception e){
            System.debug('insert method execution under catch block');
        }
    }
    }

//trigger code
trigger Contact_count_trigger on Contact (after insert, after update, after delete) { 

    if(trigger.isAfter && Trigger.isInsert){ 
        Contact_count_Handler.InsertMethod(trigger.new);
}
}
Hello There, I'm trying to fetch records from Case object but it showing error as - No such column 'Contact' on entity 'Case'

my query is - 
Select id, Status, Account.Name from Case where Contact IN ('Forbes, Sean', 'Pavlova, Stella')
can anyone plz suggest if any mistake
Hello There, I have created batch class for Lead object, it's working but I  want to add try-catch block in that, it showing error when I placed these blocks, I'm not able to figure out right place to write these block maybe. can anyone plz help in this.

//this is my code

global class BatchDemo_Lead implements Database.Batchable<sObject>{
    try{
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([Select id from Lead]);
    }
        
    }
    
    global void execute(Database.BatchableContext bc, List<Lead> scope){
        
        for(Lead l : scope)
        {
            if(l.State == 'VA'){
            l.State = 'NJ';
        }
        }
        update scope;
        }
    
    global void finish(Database.BatchableContext bc){
        system.debug('Batch process finished.');
    }
    catch(Exception e){
           return Database.getQueryLocator(Select id, State from Lead);
            System.debug('DML operation executed from catch block');
    }
    }
    
Hello there, I have created custom roll up summary and now I was asked to add exception handling in that, as it's properly working code, I'm not sure where to put these try - catch block
can anyone plz help in this.

// my code
public class Contact_count_Handler 
{     
    public static void InsertMethod(List<Contact> newList){
        List<Account> accList = new List<Account>();
        
        Set<id> accountIds = new Set<id>();        
        if(newList!=null) { 
            for(contact c: newList)    
            {
                if(c.accountId!=null)            
                {
                    accountIds.add(c.accountId);
                }
            }
            if(!accountIds.isEmpty()){
                for(Account acc :[Select id,Number_of_linked_contact__c,(Select id,name from contacts) from Account where Id in : accountIds]){            
                    acc.Number_of_linked_contact__c= acc.contacts.size();
                    
                    acclist.add(acc);
                }
                if(acclist.size()>0){
                    update accList; 
                }
            }
        }
        
    }           
    
    public static Void updateMethod(list<Contact> newList,map<Id,Contact>oldmap ){
        List<Account> accList=new List<Account>();
        
        if(oldmap != null){
            Set<Id> setAccIds = new Set<Id>();
            for(Contact con : newList){ 
                if(con.AccountId != null && con.AccountId != oldMap.get(con.Id).AccountId){
                    setAccIds.add(con.AccountId); 
                    setAccIds.add(oldMap.get(con.Id).AccountId);
                }   
            }
            if(!setAccIds.isEmpty()){
                
                for(Account acc :[Select id,Number_of_linked_contact__c,(Select id,name from contacts) from Account where Id in : setAccIds]){
                    
                    acc.Number_of_linked_contact__c= acc.contacts.size();
                    acclist.add(acc);
                }
                if(acclist.size()>0){
                    update accList; 
                }
            }
        }
    }
    
    
    public static Void deleteMethod(list<Contact> newList){
        List<Account> accList=new List<Account>();
        
        if(newList != null){
            Set<Id> setAccIds = new Set<Id>();
            for(Contact con : newList){ 
                if(con.AccountId != null){
                    setAccIds.add(con.AccountId);      
                }   
            }
            
            if(!SetAccIds.isEmpty()){
                for(Account acc :[Select id,Number_of_linked_contact__c,(Select id,name from contacts) from Account where Id in : setAccIds]){
                    
                    acc.Number_of_linked_contact__c= acc.contacts.size();
                    
                    acclist.add(acc);
                }
                if(acclist.size()>0){
                    update accList; 
                }
            }
        }
    }
}
Hello there, I was given a task to -
i)create custom object invoice with field total amount
ii)create child object invoice line item with lookup relationship to invoice
iii)add price field into invoice line item

I have created 'invoice' object and field 'total amount'
now how to create lookup relation on child object
I'm confused whether we can create relationship on object, it can be created on fields only as I know or maybe something I don't know on this.
can anyone plz guide.
Hello There, I'm writing program to fetch newly created contact and save that into a list, it's partially done I'm able to fetch and print it but how to insert it into list. plz guide.
here's my code -

trigger ContactTrigger_query on Contact (before insert, before update) {
    
    List<Contact> aclist = new List<Contact>(); 
    
    Contact[] cont = [Select name, Account.Name from contact Where id IN : Trigger.new];
        System.debug(cont[0].name +' '+ cont[0].Account.Name);
    
}
Hello there, As new to development, I referred a piece of code and trying to understand this program, some of the statements didn't understand where I put question mark
can anyone spare some time to explain once plz

//handler code - 
public class NewClass { // class name

    public static void NewMethod(List<Parent__c> newParent) { //created list using custom object parent and named it newParent

        newParent = [SELECT Id, Name, Field1__c, Field2__c WHERE Id IN: newParent]; // fetching id, name and other fields where id is matching to newParent ? but with which other object they are comparing this ? are they fetching from newParent and assigning also in newParent ? plz explain this part

        List<Child__c> childQry = new List<Child__c>(); // list created for child object
        List<Child__c> childListToUpdate = new List<Child__c>(); //another list created for child object, did not understand why 2 list created here ?

        for(Parent__c p : newParent) { // Parent object reference variable p created which will run through records saved in newParent list

            childQry = [SELECT Id, Name, Parent__c, Field1__c, Field2__c FROM Child__c WHERE Field1__c =: p.Id]; // fetching records and assigning to list

            for(Child__c c : childQry) { // loop running through childQry records

                if(p.Id != null) { // null check
                    c.Field2__c = p.Field2__c; // assigning value to field2 from parent object field2
                    childListToUpdate.add(c);   // inserting record in new list
                }

            } 

        }   
        update childListToUpdate; // updating the record, did not understand what is meaning of this, didn't we already insert record in previous line ?
    }

}

//Trigger code 
trigger NewTrigger on Child__c (after update) { if(Trigger.isAfter && Trigger.isUpdate) { NewClass.NewMethod(Trigger.New); } }
Hello there, I wrote code (by referring a website) to create custom roll up summary for account which will count number of contacts in account. it was evaluated and I was asked to optimize the code such that if contact has no account select while creating, for those contacts it should not go inside loop,
I'm new in development and actually not getting how to achieve that, can anyone plz help.

here's my code -

public class Contact_count_Handler
{     
public static void countContact(List<Contact> newList, List<Contact> oldList)
{
    Set<id> accountIds = new Set<id>();
    
if(newList!=null)  // null check
{
    for(contact c: newList)    
 {
        if(c.accountId!=null)            
{
            accountIds.add(c.accountId);
        }
    }
}

    if(oldList!=null)
    {
            for(contact c: oldList)
        {    
                if(c.accountId!=null)
            {
                    accountIds.add(c.accountId);
            }
        }
    }
List<Account> accounts = [SELECT Id, Number_of_linked_contact__c,(SELECT Id from Contacts) from Account where Id in : accountIds];
        
    if(!accounts.isEmpty())
        {
        for(Account acc: accounts)
            {
            acc.Number_of_linked_contact__c = acc.contacts.size();
            }
        }
    update accounts;
    }
}

===============================
trigger code -

trigger Contact_count_trigger on Contact (after insert, after update, after delete)
{
    if(trigger.isAfter){
        if(trigger.isInsert || trigger.isUpdate || trigger.isDelete)
{
            Contact_count_Handler.countContact(Trigger.new, Trigger.old);
        }
    }
}
Hello, I have LWC to show contact records and modal to edit the records, while editing record it shows error as fields are read-only, can anyone help.
// html

    <template>
        <lightning-card title="Contact Records">
       
            <lightning-datatable data={wireContact.data} columns={columns} key-field="id" hide-checkbox-column="true"  onrowaction={handleRowAction}  ></lightning-datatable>
           
            <template if:true={modalContainer}>
                <section  class="slds-modal slds-fade-in-open">
                    <div class="slds-modal__container">
                        <header class="slds-modal__header">
                            <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closeModalAction}>
                            <lightning-icon icon-name="utility:close" alternative-text="close" variant="inverse" size="small" ></lightning-icon>
                            </button>
                           
                            <h2 class="slds-text-heading_medium slds-hyphenate">Contact Record Detail</h2>
                        </header>
                        <div class="slds-modal__content slds-p-around_medium">
                            <table class="slds-table slds-table_bordered slds-table_col-bordered slds-table_cell-buffer">
                            <thead>
                                <tr>
                                    <th>First Name</th>
                                    <th>Last Name</th>
                                    <th>Email Name</th>
                                    <th>Phone Name</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>

                                    <td><lightning-input
                                        type="text"
                                        label="First name"
                                        value={contactRow.FirstName}
                                        onchange={handleChange}>
                                    </lightning-input></td>
                                    <td><lightning-input
                                        type="text"
                                        label="Last name"
                                        value={contactRow.LastName}
                                        onchange={handleChange}>
                                    </lightning-input></td>
                                    <td><lightning-input
                                        type="Email"
                                        label="Email"
                                        value={contactRow.Email}
                                        onchange={handleChange}>
                                    </lightning-input></td>
                                    <td><lightning-input
                                        type="tel"
                                        label="Phone"
                                        value={contactRow.Phone}
                                        onchange={handleChange}>
                                    </lightning-input> </td>
                                </tr>
                            </tbody>  
                            </table>
                        </div>
                        <footer class="slds-modal__footer">
                       
                            <lightning-button class="slds-p-horizontal_medium" id="btn1" variant="brand" label="Close" title="Close"  onclick={closeModalAction}></lightning-button>
                            <lightning-button class="slds-p-horizontal_medium" variant="brand" label="Save" title="Save" type="submit" onclick={handleSave}></lightning-button>
                       
                    </footer>
                    </div>
                </section>
                <div class="slds-backdrop slds-backdrop_open"></div>
            </template>
        </lightning-card>
    </template>

----------------------------------------------

// JS code
import { LightningElement, track, wire } from 'lwc';
import getContacts from '@salesforce/apex/LWCExampleController.getContacts';
import saveRecords from '@salesforce/apex/LWCExampleController.saveRecords';
const columns=[
    {label: 'View',type: 'button-icon', initialWidth: 75, typeAttributes: { iconName: 'action:preview', title: 'Preview',
     variant: 'border-filled', alternativeText: 'View'}
      },
    { label: 'First Name',fieldName: 'FirstName', editable: true},
    { label: 'Last Name',   fieldName: 'LastName', editable: true},
    { label: 'Email', fieldName: 'Email'},
    { label: 'Phone',   fieldName: 'Phone'}
];
export default class LwcDataTableRowAction extends LightningElement {
  @track columns = columns;
  @track contactRow={};
  @track rowOffset = 0;  
  @track modalContainer = false;
  @track saveDraftValues = [];
  @track contacts;
   @wire(getContacts) wireContact;
 
   handleRowAction(event){
      const dataRow = event.detail.row;
      window.console.log('dataRow@@ ' + dataRow);
      this.contactRow=dataRow;
      window.console.log('contactRow## ' + dataRow);
      this.modalContainer=true;
   }
 
   handleChange(event){
      if(event.target.label=='First name'){
          this.contactRow.FirstName = event.target.value;
      }
      if(event.target.label=='Last name'){
          this.contactRow.LastName = event.target.value;
      }            
      if(event.target.label=='Email'){
          this.contactRow.Email = event.target.value;
      }
      if(event.target.label=='Phone'){
         this.contactRow.Phone = event.target.value;
     }
   }
   handleSave(){
      saveRecords({ contactToUpdate: this.contactRow })
           .then((result) => {
               console.log(result);
           })
           .catch((error) => {
               console.log(error);
           });
  }
   closeModalAction(){
    this.modalContainer=false;
   }
}

-------------------------------------------------------
// apex class

public inherited sharing class LWCExampleController {
    @AuraEnabled(Cacheable = true)
    public static List<Contact> getContacts() {
        return [SELECT Id, Name, FirstName, LastName, Phone, Email
                FROM Contact
                WHERE Email != null
                AND Phone != null
                ORDER BY CreatedDate DESC NULLS LAST limit 10];
    }
    @AuraEnabled
   public static void saveRecords(Contact contactsToUpdate){
   
    update contactsToUpdate;
   }
}
Hello there, I have LWC to show contact records and modal to edit the records, I'm able to fetch records and editing also showing but don't know how to run query to update records, pls look into my code and suggest.

//html 
  <!-- <template>
    <c-record_modal></c-record_modal>
    <lightning-card title="Contact Records" style="font-size: 10px">
        <template if:true={contacts.data}>
            <lightning-datatable key-field="Id"
                                 data={contacts.data}
                                 columns={columns}
                                 onsave={handleSave}
                                 draft-values={saveDraftValues}
                                 hide-checkbox-column
                                 show-row-number-column>
                                </lightning-datatable>
        </template>
           
    </lightning-card>
</template> -->

<template>
    <lightning-card title="Contact Records">
       
        <lightning-datatable data={wireContact.data} columns={columns} key-field="id" hide-checkbox-column="true"  onrowaction={handleRowAction}></lightning-datatable>
       
        <template if:true={modalContainer}>
            <section  class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <header class="slds-modal__header">
                        <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closeModalAction}>
                           <lightning-icon icon-name="utility:close" alternative-text="close" variant="inverse" size="small" ></lightning-icon>
                        </button>
                       
                        <h2 class="slds-text-heading_medium slds-hyphenate">Contact Record Detail</h2>
                     </header>
                     <div class="slds-modal__content slds-p-around_medium">
                        <table class="slds-table slds-table_bordered slds-table_col-bordered slds-table_cell-buffer">
                           <thead>
                            <tr>
                                <th>First Name</th>
                                <th>Last Name</th>
                                <th>Email Name</th>
                                <th>Phone Name</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>

                                <td><lightning-input
                                    type="text"
                                    label="first name"
                                    value={contactRow.FirstName}>
                                </lightning-input></td>
                                <td><lightning-input
                                    type="text"
                                    label="Last name"
                                    value={contactRow.LastName}>
                                </lightning-input></td>
                                <td><lightning-input
                                    type="Email"
                                    label="Email"
                                    value={contactRow.Email}>
                                </lightning-input></td>
                                <td><lightning-input
                                    type="tel"
                                    label="Phone"
                                    value={contactRow.Phone}>
                                </lightning-input> </td>
                            </tr>
                        </tbody>  
                        </table>
                     </div>
                     <footer class="slds-modal__footer">
                     
                        <lightning-button class="slds-p-horizontal_medium" id="btn1" variant="brand" label="Close" title="Close"  onclick={closeModalAction}></lightning-button>
                        <lightning-button class="slds-p-horizontal_medium" variant="brand" label="Save" title="Save"  onclick={handleSave}></lightning-button>
                       
                   </footer>
                </div>
            </section>
            <div class="slds-backdrop slds-backdrop_open"></div>
        </template>
    </lightning-card>
</template>

--------------------------------------------------------------------------

//JS code

import { LightningElement, track, wire } from 'lwc';
import getContacts from '@salesforce/apex/LWCExampleController.getContacts';
const columns=[
    {
        label: 'View',
        type: 'button-icon',
        initialWidth: 75,
        typeAttributes: {
            iconName: 'action:preview',
            title: 'Preview',
            variant: 'border-filled',
            alternativeText: 'View'
        }
      },
      {
        label: 'First Name',
        fieldName: 'FirstName'
    },
    {
        label: 'Last Name',
        fieldName: 'LastName'
    },
    {
        label: 'Email',
        fieldName: 'Email'
    },
    {
        label: 'Phone',
        fieldName: 'Phone'
    }
];
export default class LwcDataTableRowAction extends LightningElement {
  @track columns = columns;
  @track contactRow={};
  @track rowOffset = 0;  
  @track modalContainer = false;
   @wire(getContacts) wireContact;
 
   handleRowAction(event){
      const dataRow = event.detail.row;
      window.console.log('dataRow@@ ' + dataRow);
      this.contactRow=dataRow;
      window.console.log('contactRow## ' + dataRow);
      this.modalContainer=true;
   }
//    handleSave(){
//     saveRecords()
//    }
   closeModalAction(){
    this.modalContainer=false;
   }
}

----------------------------------------------------------------

// class file

public inherited sharing class LWCExampleController {
    @AuraEnabled(Cacheable = true)
    public static List<Contact> getContacts() {
        return [SELECT Id, Name, FirstName, LastName, Phone, Email
                FROM Contact
                WHERE Email != null
                AND Phone != null
                ORDER BY CreatedDate DESC NULLS LAST limit 10];
    }
    // @AuraEnabled(Cacheable = true)
    // public static List<Contact> saveRecords(){
    //     return [UPDATE FirstName, LastName, Phone, Email FROM Contact] //clarification on this
    // }
}
 
Hello There, I have lwc which shows list of contact records and I added editable='true' in result page it's getting edit but not getting saved, I'm not sure where and how to query update query
Can anyone help me in writing code to save the updated record.

// html code
<template>
     <h2> Contact Datatable</h2>     
         <lightning-datatable data={wiredContacts.data} columns={columns} key-field="Id">
         </lightning-datatable>     
 </template>

// js code
import { LightningElement ,api, wire, track} from 'lwc';
import getContactList from '@salesforce/apex/method.getContactList';
export default class contactRecord extends LightningElement {
   
         @track columns = [
          { label: 'Name', fieldName: 'Name', editable: true},
          { label: 'Id', fieldName: 'Id'},
            {label: 'Email', fieldName: 'Email'}
      ];
      @track conList;
      @track error;
      @wire(getContactList)
      wiredContacts;
}

// class code
public with sharing class method {
    @AuraEnabled(cacheable=true)
    public static List<Contact> getContactList() {
        return [SELECT Id, Name, email
            FROM Contact];
    }
}
Hello there, I have created lwc for showing contact records but I want to show associated account name also but in result page it shows blank in account field
can anyone pls assist in this. my code as follows.
//html
<template>
     <h2> Contact Datatable</h2>
     <template if:true={conList}>
         <lightning-datatable data={conList} columns={columns} key-field="Id">
         </lightning-datatable>
     </template>
     <template if:true={error}>
         {error}
     </template>
 </template>

//js code
import { LightningElement ,api, wire, track} from 'lwc';
import getContactList from '@salesforce/apex/method.getContactList';
export default class contactRecord extends LightningElement {
   
         @track columns = [
          { label: 'Name', fieldName: 'Name' },
          { label: 'Id', fieldName: 'Id'},
            {label: 'Account', fieldName: 'Account.Name'},
            {label: 'Email', fieldName: 'Email'}
      ];
    @track conList;
    @track error;
    @wire(getContactList)
    wiredContacts({
        error,
        data
    }) {
        if (data) {
            this.conList = data;
        } else if (error) {
            this.error = error;
        }
    }
}
------------------------
// class code
public with sharing class method {
    @AuraEnabled(cacheable=true)
    public static List<Contact> getContactList() {
        return [SELECT Id, Name, Account.Name, email
            FROM Contact];
    }
}
--------------------------------------------------------
Hello there, I have created lwc application to show contact records, I'm able to fetch records and print in on console but it doesn't load result in app page and lightning page, it shows blank page.
can anyone pls assist in this, here's my code.

//html code
<template>
    <template for:each={wiredAccounts.data} for:item="acc">
         <p key={acc.id}>
              {acc.Name}
         </p>
    </template>
</template>

------------------------------------
// js code
import { LightningElement, wire, track } from 'lwc';
import displayCon from '@salesforce/apex/method.displayCon';
export default class ContactRecord extends LightningElement {

    @wire (displayCon) wiredAccounts({data,error}){
        if (data) {
        console.log(data);
        } else if (error) {
        console.log(error);
        }
   }
}
-----------------------------------------------
// class code
public with sharing class method {
    @AuraEnabled(cacheable=true)
   public static List<Contact> displayCon(){
    List<Contact> con;
    try {
        con = [Select Id, Name, Phone, email From Contact LIMIT 20];
    } catch (Exception e) {
        System.debug(e.getMessage());
    }
        return con;
   }
}
----------------------------------------------
//xml file

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>55.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
    </targets>
</LightningComponentBundle>

---------------------------------------
// app code

<aura:application extends="force:slds">
<c:contactRecord/>
</aura:application>
 
Hello Folks, I have created Visualforce page which shows records of account and it's editable also there's checkbox but now requirement is to make records editable only when checkbox is checked, for example if i check 3 checkbox out of 10 records then only those 3 should be editable.

can anyone help in fufilling this requirement.

//my VF code 

<apex:page standardController="account" sidebar="false" recordSetVar="records">
    
    <apex:form>
        <apex:pageBlock>
        <apex:pageBlockTable value="{!records}" var="rec">
            <apex:column headervalue="checkbox">
                <apex:inputCheckbox/>
            </apex:column>
            <apex:column>
                <apex:outputField label="name" value="{!rec.name}"/>
                <apex:facet name="header">Account name</apex:facet>
            </apex:column>
            <apex:column>
                <apex:outputField label="industry" value="{!rec.industry}"/>
            <apex:facet name="header">Industry</apex:facet>
            </apex:column>
            
            <apex:inlineEditSupport event="ondblclick"/>
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="Bottom">
            <apex:commandButton value="Save" action="{!save}" id="saveButton"/>
                <apex:commandButton value="Edit" action="{!save}" id="editButton"/>
                <apex:commandButton value="Cancel" action="{!cancel}" id="delButton"/>
                </apex:pageBlockButtons>
            
             </apex:pageBlock>
    </apex:form>
</apex:page>

 
Hello There, I have created visualforce page which returns account records, I need checkbox in the result page along with records, can anyone plz guide how i can achieve that.
User-added image

// my visualforce code

<apex:page controller="Demo2VF_Class">
<apex:form >
    <apex:pageBlock title="Account information">
        <apex:pageBlockTable value="{!acc}" var="item">
            <apex:column value="{!item.id}"/>
            <apex:column value="{!item.name}"/>
            <apex:column value="{!item.Type}"/>
            <apex:column value="{!item.rating}"/>
        
        </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>

//my class code
public class Demo2VF_Class {
    
    public List<Account> acc{get;set;}
    
    public Demo2VF_Class(){
        acc = [Select id, name, Type, Account.Rating from Account];
      
        
    }
}
Hello There, I have created visualforce page which returns account records, I need checkbox in the result page, can anyone plz guide how i can achieve that.

// my visualforce code

<apex:page controller="Demo2VF_Class">
<apex:form >
    <apex:pageBlock title="Account information">
        <apex:pageBlockTable value="{!acc}" var="item">
            <apex:column value="{!item.id}"/>
            <apex:column value="{!item.name}"/>
            <apex:column value="{!item.Type}"/>
            <apex:column value="{!item.rating}"/>
        
        </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>

//my class code
public class Demo2VF_Class {
    
    public List<Account> acc{get;set;}
    
    public Demo2VF_Class(){
        acc = [Select id, name, Type, Account.Rating from Account];
      
        
    }
}
Hello There, I have custom roll up summary handler class and trigger created seperately, I'm not aware about testing and don't know whether it will be written for handler class or trigger program. 

also can anyone help in adding test case for this insertMethod (I have 2 other method, for which I will implement with that reference )

//handler class
public class Contact_count_Handler 
{     
    public static void InsertMethod(List<Contact> newList){
        List<Account> accList = new List<Account>();
        try{
        Set<id> accountIds = new Set<id>();        
        
        if(newList!=null) {
            
            for(contact c: newList)    
            {
                if(c.accountId!=null)            
                {
                    accountIds.add(c.accountId); 
                }
            }
           
            
            if(!accountIds.isEmpty()){
                for(Account acc :[Select id,Number_of_linked_contact__c,(Select id,name from contacts) from Account where Id in : accountIds]){
                    
                    acc.Number_of_linked_contact__c= acc.contacts.size();
                    
                    acclist.add(acc);
                }
                if(acclist.size()>0){
                    update accList; 
                }
            }
        }   
        
    }
         catch(Exception e){
            System.debug('insert method execution under catch block');
        }
    }
    }

//trigger code
trigger Contact_count_trigger on Contact (after insert, after update, after delete) { 

    if(trigger.isAfter && Trigger.isInsert){ 
        Contact_count_Handler.InsertMethod(trigger.new);
}
}
Hello There, I'm trying to fetch records from Case object but it showing error as - No such column 'Contact' on entity 'Case'

my query is - 
Select id, Status, Account.Name from Case where Contact IN ('Forbes, Sean', 'Pavlova, Stella')
can anyone plz suggest if any mistake
Hello There, I have created batch class for Lead object, it's working but I  want to add try-catch block in that, it showing error when I placed these blocks, I'm not able to figure out right place to write these block maybe. can anyone plz help in this.

//this is my code

global class BatchDemo_Lead implements Database.Batchable<sObject>{
    try{
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([Select id from Lead]);
    }
        
    }
    
    global void execute(Database.BatchableContext bc, List<Lead> scope){
        
        for(Lead l : scope)
        {
            if(l.State == 'VA'){
            l.State = 'NJ';
        }
        }
        update scope;
        }
    
    global void finish(Database.BatchableContext bc){
        system.debug('Batch process finished.');
    }
    catch(Exception e){
           return Database.getQueryLocator(Select id, State from Lead);
            System.debug('DML operation executed from catch block');
    }
    }
    
Hello there, I was given a task to -
i)create custom object invoice with field total amount
ii)create child object invoice line item with lookup relationship to invoice
iii)add price field into invoice line item

I have created 'invoice' object and field 'total amount'
now how to create lookup relation on child object
I'm confused whether we can create relationship on object, it can be created on fields only as I know or maybe something I don't know on this.
can anyone plz guide.
Hello There, I'm writing program to fetch newly created contact and save that into a list, it's partially done I'm able to fetch and print it but how to insert it into list. plz guide.
here's my code -

trigger ContactTrigger_query on Contact (before insert, before update) {
    
    List<Contact> aclist = new List<Contact>(); 
    
    Contact[] cont = [Select name, Account.Name from contact Where id IN : Trigger.new];
        System.debug(cont[0].name +' '+ cont[0].Account.Name);
    
}
Hello there, I wrote code (by referring a website) to create custom roll up summary for account which will count number of contacts in account. it was evaluated and I was asked to optimize the code such that if contact has no account select while creating, for those contacts it should not go inside loop,
I'm new in development and actually not getting how to achieve that, can anyone plz help.

here's my code -

public class Contact_count_Handler
{     
public static void countContact(List<Contact> newList, List<Contact> oldList)
{
    Set<id> accountIds = new Set<id>();
    
if(newList!=null)  // null check
{
    for(contact c: newList)    
 {
        if(c.accountId!=null)            
{
            accountIds.add(c.accountId);
        }
    }
}

    if(oldList!=null)
    {
            for(contact c: oldList)
        {    
                if(c.accountId!=null)
            {
                    accountIds.add(c.accountId);
            }
        }
    }
List<Account> accounts = [SELECT Id, Number_of_linked_contact__c,(SELECT Id from Contacts) from Account where Id in : accountIds];
        
    if(!accounts.isEmpty())
        {
        for(Account acc: accounts)
            {
            acc.Number_of_linked_contact__c = acc.contacts.size();
            }
        }
    update accounts;
    }
}

===============================
trigger code -

trigger Contact_count_trigger on Contact (after insert, after update, after delete)
{
    if(trigger.isAfter){
        if(trigger.isInsert || trigger.isUpdate || trigger.isDelete)
{
            Contact_count_Handler.countContact(Trigger.new, Trigger.old);
        }
    }
}
I'm getting the same error even though I'm using the code provided by other users here. The new field is also created.
 
trigger AccountAddressTrigger on Account (before insert, before update) {
    for(Account a : Trigger.new){
        If (a.Match_Billing_Address__c == true) {
            a.ShippingPostalCode = a.BillingPostalCode;
        }   
    }
}

Is there anything wrong with it? 

Thanks in advance.
User-added imageIs there a way to add a link/button to this dropdown menu.  It is on an existing Account list view on a lightning page.  The list view has about 30 accounts.  The only options are edit, delete, and change owner.  We have a custom button that sits on the Account record page to generate a data file for export to a third party.  It would save end-users a ton of time if we could put the link there, instead of them having to click into each account record to generate the file.  Any ideas?