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

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 5
    Likes Given
  • 37
    Questions
  • 31
    Replies
How to delete apex log quickly because given method of selecting queries and then delete actually takes much longer than expected and continuous monitoring.
Hello Experts, my component is fetching query result from class and showing in Aura App console but doesn't work in LWC experience builder. I tried running it on load and through button click also, it doesn't give any result, array shows blank, length 0. I tested in anonymous window this query fetches result. I don't know what I'm missing. Please guide.
import { LightningElement, track,api, wire } from 'lwc';
import getNotes from '@salesforce/apex/TBT_SupervisorNotes.getNotes';


export default class tBT_SessionGuideline extends LightningElement {
    @wire(getNotes) gnotes;
    @track getNotes;
    @track datalist = [];

  connectedCallback(){
        getNotes().then(res => {
            this.datalist = res;
            console.log('hi');
             console.log("result from connected callback", res);
            console.log("datalist result from connected callback", this.datalist);
        }).catch((error)=>{
            console.error("error " ,JSON.stringify(error));
        })
    }
public class TBT_supervisorNotes {

@AuraEnabled(Cacheable=true)
public static List<Input_Form__c> getNotes(){
    
    List<Input_Form__c> LognotesList = [ select id, Session_Summary__c from input_form__c where recordtype.name = 'TBT Supervisor Log Notes' ];

    system.debug(LognotesList);
    return LognotesList;
}
LWCAura

 
I'm calling getLognotes() on click of button but it's showing nothing in console. I tried to call it from connected callback but when I do that the whole page gets disappear, so I tried button click approach but no go. Even 'Hi' is not getting printed so I think on I'm not even getting inside function.
 
import { LightningElement, track,api, wire } from 'lwc';
import getContentNote from '@salesforce/apex/TBT_SupervisorLog.getContentNote';


export default class tBT_SessionGuideline extends LightningElement {


// connectedCallback(){
//     this._getLogNotes(); // this not working
// }

_getLogNotes(){
    getLogNotes(action).then(res => {
        this.getContentNote = res;
        console.log('hi');
        console.log("content notes result", this.getContentNote);
    }).catch((error)=>{
        console.error("content notes error " ,JSON.stringify(error));
    })
}


*My apex class*
public with sharing class TBT_SupervisorLog {

@AuraEnabled(Cacheable=true)
public static List<ContentNote> getContentNote(){
Set<Id> contactIds = new Set<Id>();
contactIds.add('0030100000ABCD');

Set<Id> contentLinkIds = new Set<Id>();

for(ContentDocumentLink conLink : [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId IN :contactIds]){
    contentLinkIds.add(conLink.ContentDocumentId);
}
List<ContentNote> NoteList = [select id, ContentModifiedDate,  LastModifiedBy.name from ContentNote where Id IN : contentLinkIds ];
    System.debug(NoteList);  
return NoteList;
    }
}
I checked in debug log it's fetching result from class.Please if someone could guide.
 

Hello in my LWC I'm showing all records in page and I want to show only those records which are matching with record id from url.
I tried with @api recordId but that didn't bring result I'm doubtful whether my implementation was correct.
I also tried with event.target.value but that showing error.
import getActiveSessions from '@salesforce/apex/DCController.TBT_getActiveSessions';


_getActiveSessions(){
  getActiveSessions().then(response=>{
    this.dataToDisplay = response
    // for(let i=0;i< this.dataToDisplay.length; i++){
    //     if(this.dataToDisplay[i].id == recordId){           // I tried this way but not getting through it
    //         this.clientData[i] = this.dataToDisplay[i];  
    //     }
    // }
    console.log(response)
  }).catch(error=>{
    console.log(error)
  })
  ;
  console.log('client data '+clientData);
}
//event query running in apex class and that result is coming to LWC by getActiveSessions method

Select Id, Subject, WhatId, WhoId, Who.Name, EndDate, EndDateTime,Start_Date_Time__c , OwnerId, ActivityDate, ActivityDateTime, Facilities__c,Facilities__r.Name, Services__c, Appointment_Status__c, Description, DC_Session_Start_Time__c, DC_Session_End_Time__c, DC_Session_Run_Time__c, DC_Session_Status__c, DC_Session_Last_Start_Time__c, End_Time__c, IsRecurrence, DOSSession__c, What.Name From Event'
can anyone please look into it and guide.

 
Hello there, I have list of case on which I'm getting my case query result, now based on condition that - OldValue not null condition I want to get those records into new List.
Basically my aim is to filter out those record which has OldValue, newValue (which is coming from Histories field tracking )
 
public static void SessionHistory(){
        try {

            Map<id,list<case>> UserEvent = new Map<id,list<case>>();
            List<case> tempCaseList = null;
            List<case> newEvents1 = new List<case>();

           List<case> newEvents = [SELECT OwnerId,(SELECT OldValue, id, NewValue, CreatedById, CreatedBy.Name, caseId,  case.Ownerid, case.DOS__c FROM Histories where field='status'), Account.Name, Patient_Customer__r.dob__c, CaseNumber,Status,Appointment_Start_Time__c,Appointment_End_Time__c, 
            DOS__c,FacilitiesV3__c,Place_of_Service__c,Practice_Procedure_Code__c,Practice_Procedure_Code__r.Type_of_Service__c,
            Insurance__c,Duration__c, Actual_Duration__c, Unit__c, Actual_Unit__c, Practice_Procedure_Code__r.name, Billed_Amount__c,
            Id,Authorizations__c,Facility_Type__c, Patient_Customer__c, PA_NO_PA__c,Provider__c, Client_Insurance__c,Authorization_Number__c,
            Client_Name__c, Provider_Name__c, Location_Name__c,Insurance_Name__c, Sup_Provider__r.Name FROM Case WHERE Recordtype.Name ='Session'
             ORDER BY OwnerId limit 1800];


             if(newEvents.contains(OldValue)){
               newEvents1.addAll(newEvents);
             }

             system.debug('new history'+ newEvents1);
I tried with listname.contains('OldValue') but it's not working. Please if someone can suggest right approach. It will be very helpful.
 
Hello Expert, I have a method on which I'm running loop for showing all records of particular user(account). I'm getting index number in result. I want to show id of user instead of index number.
 
public static void methodEventData2(){
    try {

        Map<id,list<event>> UserEvent2 = new Map<id,list<event>>();
        List<event> tempEventList = null;

        List<Event> newEvents = [Select Id, Subject, WhatId, WhoId, Who.Name, EndDate, EndDateTime,Start_Date_Time__c, OwnerId, 
            ActivityDate, ActivityDateTime, Facilities__c,Facilities__r.Name, Services__c, Appointment_Status__c, Description, 
            DC_Session_End_Time__c,DC_Session_Last_Start_Time__c,DC_Session_Run_Time__c,DC_Session_Start_Time__c,
            DC_Session_Status__c, End_Time__c, IsRecurrence, Sup_Provider__c, DOSSession__c, What.Name,Owner.Name From Event WHERE 
             whoid != null order by OwnerId limit 200];

            
            for(event et : newEvents){
            if(!UserEvent2.isEmpty() || UserEvent2 !=null){
                if(UserEvent2.get(et.OwnerId) != null){
                    tempEventList.add(et);
                    UserEvent2.put(et.OwnerId, tempEventList);
                }
                else{
                    tempEventList = new List<event>();
                    tempEventList.add(et);
                    UserEvent2.put(et.OwnerId, tempEventList);
                }
            }
         }



        Set<Id> keySet = UserEvent2.keySet();



        String body='{';
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://test/Appointments.json');
        request.setMethod('PATCH');
        
        for(id ownerId : keySet)
        {
            body=body+'"'+Ownerid+'" :'+JSON.serialize(UserEvent2.get(ownerId))+',';
        }
        body=body.removeEnd(',');
        body=body+'}';
        request.setBody(body);
        HttpResponse response = http.send(request);
}

when I'm writing tempEventList.add(et.OwnerId), it's showing error. Can anyone please guide as to how I can print ownerId in result instead of index number (0,1,2..). Please help
Hello Experts, I have a normal method which I want to make it Batchable as it should be executed on given time. It's the first time to work with Batch apex. Can anyone please guide how to implement this.
public static void firebaseDashboardData(){
        try {
           Map<Id,Integer> sessionCountMap= TBT_EventQuerySelector.getSessionCount();
           Map<Id,Integer> activeSessionCountMap=TBT_EventQuerySelector.getActiveSessionCount();
           List<DashboardWrapper> dashboardDataList=new  List<DashboardWrapper>();
           Set<Id> keySet = sessionCountMap.keySet();
           for(Id key : keySet){
               if(activeSessionCountMap.containsKey(key)) {
               DashboardWrapper data=new DashboardWrapper();
               data.userId=key ;
               data.sessionCount=sessionCountMap.get(key );
               data.activeSessionCount=activeSessionCountMap.get(key );
               dashboardDataList.add(data);
               }
               
           }
            
            String body='{';
            Http http = new Http();
            HttpRequest request = new HttpRequest();
            request.setEndpoint('https://test/UserDashboard.json');
            request.setMethod('PATCH');
            
            for(DashboardWrapper dW: dashboardDataList)
            {
                body=body+'"'+dw.userId+'" :'+JSON.serialize(dw)+',';
            }
            body=body.removeEnd(',');
            body=body+'}';
            request.setBody(body);
            HttpResponse response = http.send(request);
            // If the request is successful, parse the JSON response.
            if(response.getStatusCode() == 200) {
                // Deserialize the JSON string into collections of primitive data types.
                Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
                System.debug(results);
                JSON.deserializeUntyped(response.getBody());
                //     System.debug(results);
            }
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }

Any help would be highly appreciated.
Hello Experts, I'm working on exporting the data in excel format, report is getting generated but the date format needs to be changed.
here's my Js function
exportNBReport() {
		let doc = '<table>';
		// Add styles for the table
		doc += '<style>';
		doc += 'table, th, td {';
		doc += '    border: 1px solid black;';
		doc += '    border-collapse: collapse;';
		doc += '}';
		doc += '</style>';
		// Add all the Table Headers
		doc += '<tr>';
		this.columnHeader.forEach(element => {
			doc += '<th>' + element + '</th>'
		});
		//alert(JSON.stringify(this.planData));
		doc += '</tr>';
		// Add the data rows
		this.event_session_Array.forEach(record => {
			doc += '<tr>';
      if (record.ProviderName != undefined) {
				doc += '<th>' + record.ProviderName + '</th>';
			} else {
				doc += '<th>' + '</th>';
			}
      if (record.ServiceType1 != undefined) {
				doc += '<th>' + record.ServiceType1 + '</th>';
			} else {
				doc += '<th>' + '</th>';
			}
     
      if (record.AppointmentStart != undefined) {
				doc += '<th>' + record.AppointmentStart + '</th>';
			} else {
				doc += '<th>' + '</th>';
			}
 doc += '</tr>';
		});
		

		doc += '</table>';
		var element = 'data:application/vnd.ms-excel,' + encodeURIComponent(doc);

		let downloadElement = document.createElement('a');
		downloadElement.href = element;
		downloadElement.target = '_self';
		downloadElement.download = 'Appointment Report.xls';
		document.body.appendChild(downloadElement);
		downloadElement.click();
  }

this code is working properly and generating Excel sheet which looks like 
2022-12-30T08:00:00.000Z
2022-12-31T03:45:00.000Z
2023-01-02T02:15:00.000Z
2023-01-03T15:00:00.000Z
2023-01-08T19:30:00.000Z
2023-01-09T19:30:00.000Z
2023-01-10T19:30:00.000Z

I want it to be as - Friday, Dec 30, 2022, 3 AM (this format)
Can anyone please help !!
 
Hello Experts, I have Apex class where I'm running query under a method and this goes to JS page but I don't know how to pass the data back to Apex.
@AuraEnabled  //dynamic filter
    public static List<queryWrap> DynamicFilter(String startDate, String endDate, String Provider){

        String status1 = 'Non-Billable';
        
        String evtQuery = 'Select Id, Start_Date_Time__c, EndDateTimeV3__c, Additional_Provider_Name__c, Subject from Event where Appointment_status__c = :status1';
        
        if(!String.isBlank(startDate)){
            Datetime stDate = date.parse(startDate);
            evtQuery = evtQuery + ' AND Start_Date_Time__c =: startDate';
        }
        
        if(!String.isBlank(endDate)){
            Datetime enDate = date.parse(endDate);
            evtQuery = evtQuery + ' AND EndDateTimeV3__c =: endDate';
        }

        if(!String.isBlank(Provider)){
            evtQuery = evtQuery + ' AND Additional_Provider_Name__c =:Provider';
        }

 Please Suggest !
Hello Dev, I'm trying to merge 2 SOQL queries into one. I don't know with which field it can be linked between case and event because when I'm trying with query -
Select Subject, Id, Facilities__c from event WHERE Event.WhatId = case.id 

it doesn't return anything. I believe with WhatId it can be linked but not getting proper way to implement this.
My 2 queries are - 
List<Event> nonBill = [Select Subject, Id, Facilities__c, Services__c, Appointment_Status__c, OwnerId, WhoId,ActivityDateTime, ActivityDate, WhatId,Facilities__r.Address_1__c,Facilities__r.City__c, Facilities__r.Name,Facilities__r.Country__c, Sup_Provider__c,Sup_Provider__r.Name, Owner.FirstName, Owner.MiddleName, Owner.LastName,EndDateTime, Facilities__r.State__c, Sup_Provider__r.Provider_Role__c FROM Event WHERE IsRecurrence = false AND Appointment_Status__c = 'Non-Billable'];
        
	List<Case> sessionRecords = [SELECT Id, CaseNumber, Type, RecordTypeId, Status, Reason, Origin, Subject, Priority, Description, CreatedDate, CreatedById, Comments, Duration__c, To_DOS__c, DC_Unit__c, First_Bill_Date__c, Last_Bill_Date__c, Appointment_End_Time__c, Balance__c, Billed_Amount__c, Appointment_Start_Time__c,Cal_Bal_Amt__c, Cal_Total_Patient_Bal__c,Practice_Insurance_Service__c, Client_Insurance__c, Sup_Provider__c, Claim_Number__c, Session_Summary__c, DOS__c, Labels__c,Enter_Bill_Amount__c, Total_Billed_Units__c, Total_Amounts__c, Session_Notes__c, Provider__c, Practice__c, Session_Note_Status__c, Unit__c, PA_NO_PA__c, Client_Name__c,Provider_Name__c, Location_Name__c, Insurance_Name__c, Authorization_Number__c, Self_Pay__c, Billable_Duration_in_Minutes__c, Non_Billable_Duration_in_Minutes__c,Non_Billable_Unit__c, Session_Completed_By__c FROM Case];

Please if anyone can guide on this. It will be great help !!
Hello Developers, I have apex class which consists of 2 queries and I want to merge it inside wrapper class.
here's my class
public class NonBillableReport {

    @AuraEnabled
    public static List<Event> getNonBillable(){
    List<Event> nonBill = [Select Subject, Id, Facilities__c, Services__c, Appointment_Status__c, OwnerId, WhoId,
             ActivityDateTime, ActivityDate, WhatId, Facilities__r.Address_1__c,Facilities__r.City__c, Facilities__r.Name,Facilities__r.Country__c, Sup_Provider__c,Sup_Provider__r.Name, Owner.FirstName, Owner.MiddleName, Owner.LastName,
EndDateTime, Facilities__r.State__c,
Sup_Provider__r.Provider_Role__c FROM Event WHERE IsRecurrence = false AND Appointment_Status__c = 'Non-Billable' LIMIT 100];
 return nonBill;

 List<Session> SessionRecords = [Select Case_Number__c,Case_Number__r.Client_Insurance__c,      Case_Number__r.Total_Amounts__c,Case_Number__r.Client_Insurance__r.Insurance_Type__c,Case_Number__r.Client_Insurance__r.Insured_ID__c,       Client_Name__c,Case_Number__r.Patient_Customer__r.Client_ID__c,Case_Number__r.Patient_Customer__r.DOB__c,Insurance_Name__c,     Case_Number__r.InsuranceType__c,Case_Number__r.Claim_ID__c,Case_Number__r.Insurance__r.Payer_Id__c,Case_Number__r.Insurance__r.Name,From_DOS__c,Case_Number__r.Location_Name__c,Case_Number__r.Facility_Type__c,Case_Number__r.Provider_Name__c,Case_Number__r.Provider__c,   Case_Number__r.Authorization_Number__c, Authorization_Number__c,Case_Number__r.CaseNumber , Procedure_Code__c,Modifier1__r.Name,Modifier2__r.Name,Modifier3__r.Name,Modifier4__r.Name ,Unit_Count__c, Case_Number__r.Billed_Amount__c,       Practice_Fee__c,Case_Number__r.Status,Case_Number__r.First_Bill_Date__c,Case_Number__r.Last_Bill_Date__c, ICD_Code__c,     	NDC_Code__c,NDC_Unit_Price__c,Unit_of_Measure__c,Case_Number__r.Unit__c,Case_Number__r.FacilitiesV3__c, 
Audit_Status__c,lastModifiedBy.Name, lastModifiedDate,PracticeFee__c FROM Case_Line_Item__c limit 10];
     }
}
Please help me or suggest if something is incorrect
 
Hello there, I'm doing program in which based on choice account/contact or lead has to be created.
while defining parameterized method I'm getting error as Integer (datatype) does not exist
//code

public class CIS_void_nonVoid_Pts {

    public string choice {get;set;}
    public string Acct {get;set;}
    public string con {get;set;}
    public string lead {get;set;}
    
    
    contact cn = new Contact();
        Account ac = new Account();
        lead ll = new lead();
    public void choiceMethod(){
        
        
        if(choice=='Acct'){
           AcctCreate(String X, Integer Y);
        }
       else if(choice=='con'){
            conCreate();
        }
        else if(choice =='lead'){
            leadcreate();
        }
    }
    
    void AcctCreate(String A, integer B){
        
        ac.name = A;
        ac.Phone = ''+B;
        insert ac;
    }
    
    void conCreate(){
        
        cn.lastname = ac.name +' '+'contact' ;
        insert cn;
        
    }
        void leadCreate(){
            lead ll = new lead();
            ll.lastname = cn.LastName;
            ll.Company = ac.name;
            ll.Status = 'open - not contacted';
            insert ll;
        }
    }

can anyone please help !!
Hello there, I'm facing issue while executing this program, it says string exception Specified index is invalid for j variable
I believe it's declared and initialized properly,
//my code

//palindrome
String text = 'madam';
Integer i = 0;
Integer count = 0;
string res='';
Integer j = 0;

system.debug(res.length());
for(i=0,j=text.length()-1;i<=text.length();i++){
    if(text.charAt(i)==text.charAt(j)){
        j--;
        res = res + text.charAt(i);
        
    }
    else{
           break;
        system.debug('not matched');
    }
}
if(text==res)
    system.debug('palidrome');
else
    system.debug('not palidrome');

Can anyone please check if it's incorrect, it will be great help.
Hello I'm running this program in execute anonymous window in dev console and it's giving apex time limit exceeded error.
my code - 

Integer count = 5;
Integer i = 0;
Integer sum=0;

while(i<count){
    sum = sum +i;
}
i++;
system.debug(sum);

I'm unable to figure out the issue, Please help.
Hello there, I'm unable to save the code, it shows unexpected  token: '<EOF>' 
I'm trying to save this within comment.
here's my code - 
  
 
  
  /*        Map<String,String> NDCM = new Map<String,String>{'K'=>'111'};
        Map<String,String> CGCM = new Map<String,String>{'B'=>'222'};
            Map<String,String> TNCM = new Map<String,String>{'KS'=>'333'};
  

        Map<String, Map<String,String>> IN_ST_L = new Map<String, Map<String,String>>{'New Delhi'=> NDCM, 'Chhattisgarh'=> CGCM, 'Telangana'=> TNCM };
        Map<String, Map<String,String>> US_ST_L = new Map<String, Map<String,String>>{'New York'=> NDCM, 'Texas'=> CGCM, 'FLorida'=> TNCM };

Map<String, Map<String, Map<String,String>>> C_ST_CML = new Map<String, Map<String, Map<String,String>>>{'INDIA'=> IN_ST_L, 'USA'=> US_ST_L};
System.debug(C_ST_CML);*/

Please help !
Hello there, I'm doing trailhead task and while doing 'debug your code' section I'm unable to find sfdx: toggle checkpoint
I tried on new playground also, same issue
I checked Environment variable under preference > settings > Salesforcedx-vscode-apex › Java: Home it is set as my java jdk path 'C:\Program Files\Java\jdk-17.0.4'
can anyone help in this issue please.
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
    // }
}
 
How to delete apex log quickly because given method of selecting queries and then delete actually takes much longer than expected and continuous monitoring.
Hello there, I have list of case on which I'm getting my case query result, now based on condition that - OldValue not null condition I want to get those records into new List.
Basically my aim is to filter out those record which has OldValue, newValue (which is coming from Histories field tracking )
 
public static void SessionHistory(){
        try {

            Map<id,list<case>> UserEvent = new Map<id,list<case>>();
            List<case> tempCaseList = null;
            List<case> newEvents1 = new List<case>();

           List<case> newEvents = [SELECT OwnerId,(SELECT OldValue, id, NewValue, CreatedById, CreatedBy.Name, caseId,  case.Ownerid, case.DOS__c FROM Histories where field='status'), Account.Name, Patient_Customer__r.dob__c, CaseNumber,Status,Appointment_Start_Time__c,Appointment_End_Time__c, 
            DOS__c,FacilitiesV3__c,Place_of_Service__c,Practice_Procedure_Code__c,Practice_Procedure_Code__r.Type_of_Service__c,
            Insurance__c,Duration__c, Actual_Duration__c, Unit__c, Actual_Unit__c, Practice_Procedure_Code__r.name, Billed_Amount__c,
            Id,Authorizations__c,Facility_Type__c, Patient_Customer__c, PA_NO_PA__c,Provider__c, Client_Insurance__c,Authorization_Number__c,
            Client_Name__c, Provider_Name__c, Location_Name__c,Insurance_Name__c, Sup_Provider__r.Name FROM Case WHERE Recordtype.Name ='Session'
             ORDER BY OwnerId limit 1800];


             if(newEvents.contains(OldValue)){
               newEvents1.addAll(newEvents);
             }

             system.debug('new history'+ newEvents1);
I tried with listname.contains('OldValue') but it's not working. Please if someone can suggest right approach. It will be very helpful.
 
Hello Expert, I have a method on which I'm running loop for showing all records of particular user(account). I'm getting index number in result. I want to show id of user instead of index number.
 
public static void methodEventData2(){
    try {

        Map<id,list<event>> UserEvent2 = new Map<id,list<event>>();
        List<event> tempEventList = null;

        List<Event> newEvents = [Select Id, Subject, WhatId, WhoId, Who.Name, EndDate, EndDateTime,Start_Date_Time__c, OwnerId, 
            ActivityDate, ActivityDateTime, Facilities__c,Facilities__r.Name, Services__c, Appointment_Status__c, Description, 
            DC_Session_End_Time__c,DC_Session_Last_Start_Time__c,DC_Session_Run_Time__c,DC_Session_Start_Time__c,
            DC_Session_Status__c, End_Time__c, IsRecurrence, Sup_Provider__c, DOSSession__c, What.Name,Owner.Name From Event WHERE 
             whoid != null order by OwnerId limit 200];

            
            for(event et : newEvents){
            if(!UserEvent2.isEmpty() || UserEvent2 !=null){
                if(UserEvent2.get(et.OwnerId) != null){
                    tempEventList.add(et);
                    UserEvent2.put(et.OwnerId, tempEventList);
                }
                else{
                    tempEventList = new List<event>();
                    tempEventList.add(et);
                    UserEvent2.put(et.OwnerId, tempEventList);
                }
            }
         }



        Set<Id> keySet = UserEvent2.keySet();



        String body='{';
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://test/Appointments.json');
        request.setMethod('PATCH');
        
        for(id ownerId : keySet)
        {
            body=body+'"'+Ownerid+'" :'+JSON.serialize(UserEvent2.get(ownerId))+',';
        }
        body=body.removeEnd(',');
        body=body+'}';
        request.setBody(body);
        HttpResponse response = http.send(request);
}

when I'm writing tempEventList.add(et.OwnerId), it's showing error. Can anyone please guide as to how I can print ownerId in result instead of index number (0,1,2..). Please help
Hello Dev, I'm trying to merge 2 SOQL queries into one. I don't know with which field it can be linked between case and event because when I'm trying with query -
Select Subject, Id, Facilities__c from event WHERE Event.WhatId = case.id 

it doesn't return anything. I believe with WhatId it can be linked but not getting proper way to implement this.
My 2 queries are - 
List<Event> nonBill = [Select Subject, Id, Facilities__c, Services__c, Appointment_Status__c, OwnerId, WhoId,ActivityDateTime, ActivityDate, WhatId,Facilities__r.Address_1__c,Facilities__r.City__c, Facilities__r.Name,Facilities__r.Country__c, Sup_Provider__c,Sup_Provider__r.Name, Owner.FirstName, Owner.MiddleName, Owner.LastName,EndDateTime, Facilities__r.State__c, Sup_Provider__r.Provider_Role__c FROM Event WHERE IsRecurrence = false AND Appointment_Status__c = 'Non-Billable'];
        
	List<Case> sessionRecords = [SELECT Id, CaseNumber, Type, RecordTypeId, Status, Reason, Origin, Subject, Priority, Description, CreatedDate, CreatedById, Comments, Duration__c, To_DOS__c, DC_Unit__c, First_Bill_Date__c, Last_Bill_Date__c, Appointment_End_Time__c, Balance__c, Billed_Amount__c, Appointment_Start_Time__c,Cal_Bal_Amt__c, Cal_Total_Patient_Bal__c,Practice_Insurance_Service__c, Client_Insurance__c, Sup_Provider__c, Claim_Number__c, Session_Summary__c, DOS__c, Labels__c,Enter_Bill_Amount__c, Total_Billed_Units__c, Total_Amounts__c, Session_Notes__c, Provider__c, Practice__c, Session_Note_Status__c, Unit__c, PA_NO_PA__c, Client_Name__c,Provider_Name__c, Location_Name__c, Insurance_Name__c, Authorization_Number__c, Self_Pay__c, Billable_Duration_in_Minutes__c, Non_Billable_Duration_in_Minutes__c,Non_Billable_Unit__c, Session_Completed_By__c FROM Case];

Please if anyone can guide on this. It will be great help !!
Hello Developers, I have apex class which consists of 2 queries and I want to merge it inside wrapper class.
here's my class
public class NonBillableReport {

    @AuraEnabled
    public static List<Event> getNonBillable(){
    List<Event> nonBill = [Select Subject, Id, Facilities__c, Services__c, Appointment_Status__c, OwnerId, WhoId,
             ActivityDateTime, ActivityDate, WhatId, Facilities__r.Address_1__c,Facilities__r.City__c, Facilities__r.Name,Facilities__r.Country__c, Sup_Provider__c,Sup_Provider__r.Name, Owner.FirstName, Owner.MiddleName, Owner.LastName,
EndDateTime, Facilities__r.State__c,
Sup_Provider__r.Provider_Role__c FROM Event WHERE IsRecurrence = false AND Appointment_Status__c = 'Non-Billable' LIMIT 100];
 return nonBill;

 List<Session> SessionRecords = [Select Case_Number__c,Case_Number__r.Client_Insurance__c,      Case_Number__r.Total_Amounts__c,Case_Number__r.Client_Insurance__r.Insurance_Type__c,Case_Number__r.Client_Insurance__r.Insured_ID__c,       Client_Name__c,Case_Number__r.Patient_Customer__r.Client_ID__c,Case_Number__r.Patient_Customer__r.DOB__c,Insurance_Name__c,     Case_Number__r.InsuranceType__c,Case_Number__r.Claim_ID__c,Case_Number__r.Insurance__r.Payer_Id__c,Case_Number__r.Insurance__r.Name,From_DOS__c,Case_Number__r.Location_Name__c,Case_Number__r.Facility_Type__c,Case_Number__r.Provider_Name__c,Case_Number__r.Provider__c,   Case_Number__r.Authorization_Number__c, Authorization_Number__c,Case_Number__r.CaseNumber , Procedure_Code__c,Modifier1__r.Name,Modifier2__r.Name,Modifier3__r.Name,Modifier4__r.Name ,Unit_Count__c, Case_Number__r.Billed_Amount__c,       Practice_Fee__c,Case_Number__r.Status,Case_Number__r.First_Bill_Date__c,Case_Number__r.Last_Bill_Date__c, ICD_Code__c,     	NDC_Code__c,NDC_Unit_Price__c,Unit_of_Measure__c,Case_Number__r.Unit__c,Case_Number__r.FacilitiesV3__c, 
Audit_Status__c,lastModifiedBy.Name, lastModifiedDate,PracticeFee__c FROM Case_Line_Item__c limit 10];
     }
}
Please help me or suggest if something is incorrect
 
Hello there, I'm doing program in which based on choice account/contact or lead has to be created.
while defining parameterized method I'm getting error as Integer (datatype) does not exist
//code

public class CIS_void_nonVoid_Pts {

    public string choice {get;set;}
    public string Acct {get;set;}
    public string con {get;set;}
    public string lead {get;set;}
    
    
    contact cn = new Contact();
        Account ac = new Account();
        lead ll = new lead();
    public void choiceMethod(){
        
        
        if(choice=='Acct'){
           AcctCreate(String X, Integer Y);
        }
       else if(choice=='con'){
            conCreate();
        }
        else if(choice =='lead'){
            leadcreate();
        }
    }
    
    void AcctCreate(String A, integer B){
        
        ac.name = A;
        ac.Phone = ''+B;
        insert ac;
    }
    
    void conCreate(){
        
        cn.lastname = ac.name +' '+'contact' ;
        insert cn;
        
    }
        void leadCreate(){
            lead ll = new lead();
            ll.lastname = cn.LastName;
            ll.Company = ac.name;
            ll.Status = 'open - not contacted';
            insert ll;
        }
    }

can anyone please help !!
Hello there, I'm facing issue while executing this program, it says string exception Specified index is invalid for j variable
I believe it's declared and initialized properly,
//my code

//palindrome
String text = 'madam';
Integer i = 0;
Integer count = 0;
string res='';
Integer j = 0;

system.debug(res.length());
for(i=0,j=text.length()-1;i<=text.length();i++){
    if(text.charAt(i)==text.charAt(j)){
        j--;
        res = res + text.charAt(i);
        
    }
    else{
           break;
        system.debug('not matched');
    }
}
if(text==res)
    system.debug('palidrome');
else
    system.debug('not palidrome');

Can anyone please check if it's incorrect, it will be great help.
Hello there, I'm unable to save the code, it shows unexpected  token: '<EOF>' 
I'm trying to save this within comment.
here's my code - 
  
 
  
  /*        Map<String,String> NDCM = new Map<String,String>{'K'=>'111'};
        Map<String,String> CGCM = new Map<String,String>{'B'=>'222'};
            Map<String,String> TNCM = new Map<String,String>{'KS'=>'333'};
  

        Map<String, Map<String,String>> IN_ST_L = new Map<String, Map<String,String>>{'New Delhi'=> NDCM, 'Chhattisgarh'=> CGCM, 'Telangana'=> TNCM };
        Map<String, Map<String,String>> US_ST_L = new Map<String, Map<String,String>>{'New York'=> NDCM, 'Texas'=> CGCM, 'FLorida'=> TNCM };

Map<String, Map<String, Map<String,String>>> C_ST_CML = new Map<String, Map<String, Map<String,String>>>{'INDIA'=> IN_ST_L, 'USA'=> US_ST_L};
System.debug(C_ST_CML);*/

Please help !
Hello there, I'm doing trailhead task and while doing 'debug your code' section I'm unable to find sfdx: toggle checkpoint
I tried on new playground also, same issue
I checked Environment variable under preference > settings > Salesforcedx-vscode-apex › Java: Home it is set as my java jdk path 'C:\Program Files\Java\jdk-17.0.4'
can anyone help in this issue please.
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>

 
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?      
Hi, I am new to LWC ​​​​​​, trying dynamically add/remove rows for a table scenario. I can able to add the row by click on the + button. After added that rows I want to enter some values in text boxes and save into account object by click on save buttton. Also do the delete action as well to delete the specific row by click on delete button. 

I am facing issue with save & delete records. How I can solve this? Can anyone give me some guidence to solve.

AddDeleteRow
dynamicAddRow.html

<template>
                  
    <div class="slds-m-around--xx-large">
        <div class="slds-float_right slds-p-bottom_small">
            <h1 class="slds-page-header__title">Add Row
                <lightning-button-icon icon-name="utility:add"  size="large" variant="bare" alternative-text="Add" onclick={addRow}> </lightning-button-icon>
            </h1>
        </div>
        <div class="container-fluid">        
            <table class="slds-table slds-table_bordered slds-table_cell-buffer"> 
                <thead>
                    <tr class="slds-text-title_caps">
                        <th scope="col">
                            <div class="slds-truncate">#</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Account Name">Account Name</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Account Number">Account Number</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Phone">Phone</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Action">Action</div>
                        </th>
                    </tr>
                </thead>   
                <tbody>      
                    
                    <template for:each={accountList} for:item="acc" for:index="index">
                        <tr key={acc.Id}> 
                            <td>{index}</td>                                                  
                            <td>
                                <lightning-input label="Name" value={acc.Name} onchange={handleNameChange}></lightning-input>                               
                            </td>
                            <td>
                                <lightning-input label="Account Number" value={acc.AccountNumber} onchange={handleAccountNumberChange}></lightning-input>                        
                            </td>
                            <td>
                                <lightning-input label="Phone" value={acc.Phone} onchange={handlePhoneChange}></lightning-input>
                            </td>
                            <td>
                                <a onclick={removeRow}> 
                                    <lightning-icon icon-name="utility:delete" size="small" style="margin-top: -4px; margin-right: 0px;" ></lightning-icon>
                                    <span class="slds-assistive-text">Delete</span>
                                </a>
                            </td> 
                        </tr>
                    </template>
                     
                </tbody>
            </table>
            <div class="slds-align_absolute-center slds-p-top_small">                
                <lightning-button name="Save" label="Save" onclick={saveRecord} ></lightning-button>
            </div>
        </div>
    </div>

</template>
 
dynamicAddRow.js

import { LightningElement, track,api } from 'lwc';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import ACCOUNTNUMBER_FIELD from '@salesforce/schema/Account.AccountNumber';
import PHONE_FIELD from '@salesforce/schema/Account.Phone';
import saveAccounts from '@salesforce/apex/AccountController.saveAccounts';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class CreateDynamicRecord extends LightningElement {
    @track accountList = []; 
    @track index = 0;
    @api recordId;
    @track name = NAME_FIELD;
    @track industry = ACCOUNTNUMBER_FIELD;
    @track phone = PHONE_FIELD;

    @api record = {
        firstName : '',
        lastName : '',
        Email : '',
        Phone : '',
        Title : ''
    }

    addRow(){

        this.index++;
   
        this.accountList.push ({
            sobjectType: 'Account',
            Name: '',
            AccountNumber : '',
            Phone: ''
        });

        console.log('Enter ',this.accountList);
        
       // this.accountList.push(this.record);
        //console.log(' After adding Record List ', this.accountList);
    }
    
    removeRow(){

        var index = this.index;
      
        if(this.accountList.length>1)
           this.accountList.splice(index, 1);

        //this.dispatchEvent(new CustomEvent('deleterow', {detail: this.index}));
        //console.log(' After adding Record List ', this.dispatchEvent);
    } 

    acc = {
        Name : this.name,
        AccountNumber : this.accNumber,
        Phone : this.phone
    }

    handleNameChange(event) {
        this.acc.Name = event.target.value;
        console.log("name", this.acc.Name);
    }
    
    handleAccountNumberChange(event) {
        this.acc.AccountNumber = event.target.value;
        console.log("AccountNumber", this.acc.AccountNumber);
    }
    
    handlePhoneChange(event) {
        this.acc.Phone = event.target.value;
        console.log("Phone", this.acc.Phone);
    }
    
    saveRecord(){        
        saveAccounts(this.acc.accountList)
            .then(result => {
                this.message = result;
                this.error = undefined;
                if(this.message !== undefined) {
                    this.acc.Name = '';
                    this.acc.AccountNumber = '';
                    this.acc.Phone = '';
                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Success',
                            message: 'Account created successfully',
                            variant: 'success',
                        }),
                    );
                }
                
                console.log(JSON.stringify(result));
                console.log("result", this.message);
                /*console.log(' After adding Record List ', result);
                this.accountList = result;
                console.log(' After adding Record List ', this.accountList);*/
            })
            .catch(error => {
                this.message = undefined;
                this.error = error;
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error creating record',
                        message: error.body.message,
                        variant: 'error',
                    }),
                );
                console.log("error", JSON.stringify(this.error));
            });
    }
      
}
 
AccountController.apex  

public with sharing class AccountController { 
 
    @AuraEnabled( cacheable = true ) 
    public static List< Account > getAccounts() { 
      
        return [ SELECT Id, Name, Industry FROM Account LIMIT 10 ]; 
         
    } 
     
    @AuraEnabled( cacheable = true )
    public static void saveAccounts(List<Account> accList){
        Insert accList;
        /*if(accList.size()>0 && accList != null){
            insert accList;
        }*/
    } 
}
Thanks 
Siva
 
If anyone gets this error message: "The dashboard configuration that allows users to see only their own data is incorrect"...
error message

The solution is to check The Dashboard Viewer radio button in the dashboard settings--in the "View Dashboard As" section.
Hi,

I'm not able to complete #2 Automate Accounts. It give me the following error.
"Challenge Not yet complete... here's what's wrong:
Please check the configuration of the custom fields on the Account object. The formulas, rollup summaries, etc. did not produce the expected outcome."


Can anyone tell me what went wrong? Thanks.

My Custom Fields configuration are as following:
  • Number of deals (Roll-Up Summary field): Count Opportunity. No filter criteria
  • Number of won deals (Roll-Up Summary field): Count Opportunity with filter criteria as "Stage equals Closed Won"
  • Last won deal date (Roll-Up Summary field): MAX(Opportunity: Close Date) with filter criteria as "Stage equals Closed Won"
  • Deal win % (Formula field): Number_of_won_deals__c / Number_of_deals__c
  • Total amount of won deals (Roll-Up Summary field): SUM(Opportunity: Amount) with filter criteria as "Stage equals Closed Won"
  • Call for Service (Formula field): IF( DATE( YEAR(Last_won_deal_date__c)+2 , MONTH(Last_won_deal_date__c) , DAY(Last_won_deal_date__c) ) <= TODAY(), 'YES', 'NO')
Create an Apex class that returns an array (or list) of strings: 
Create an Apex class that returns an array (or list) of formatted strings ('Test 0', 'Test 1', ...). The length of the array is determined by an integer parameter.The Apex class must be called 'StringArrayTest' and be in the public scope.
The Apex class must have a public static method called 'generateStringArray'.
The 'generateStringArray' method must return an array (or list) of strings. Each string must have a value in the format 'Test n' where n is the index of the current string in the array. The number of returned strings is specified by the integer parameter to the 'generateStringArray' method.

MyApexClass to above Challenge:

public class StringArrayTest {
    
    public static List<string> generateStringArray(Integer n)
    {
        List<String> myArray = new List<String>();
        
        for(Integer i=0;i<n;i++)
        {
            myArray.add('Test'+i);
            System.debug(myArray[i]);
        }
        return myArray;
        
    }


It's compile and execute as per requirement in Developer console. But Traihead showing the below error:

Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

Anyhelp would be greatly appreciated. Thanks.