• Priya 21
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 0
    Replies

Hi,

I have two lwc component. In that, I have radio buttons named selected and unselected. I want to populate this button value from first lwc to second.
If I click on selected for first lwc, the radio button at second lwc should also be selected. 

I am not aware of populating values of radio button in lwc.Please share some sample codes.

Hi,

I have an scenario in that we have to get record id as a parameter of the method of apex class. In apex class, it should performs update and delete operation of records for that particular record id. All these should be done while clicking the button in record page. Please give me some ideas how to call the apex class from custom button in lightning. 

Hi,
I have two record types in lead one is enquiry another is Customer. I need to transfer all related activities, attachments from enquiry to customer lead.I can have multiple Enquiry leads with same name and email and only one customer lead with that name.

Please help to update parentId of Attachments and activites of enquiry lead to customer lead.

Thanks in Advance.
 

Hi All,
 Can anyone help me to increase my test class code coverage to 100%, This is my first test class, Now my test class coverage is 85%, I want to increase the code coverage to 100%, What are the changes i need to do in my test class to get code coverage of 100%?

My Apex Class :

public class UpdateContactAddress {
    public void  updateContact(List<ID> contactId){
        List<Contact> contactSO = [Select id,MailingAddress,AccountId from Contact Where id=:contactId];
        List<Contact> contactList = new List<Contact>();
            for(Contact con : contactSO){
                //for(Account acc: [Select BillingCity,BillingStreet from Account where id=:con.AccountId]){
                       Account account = [Select BillingCity,BillingStreet from Account where id=:con.AccountId];
                        con.MailingCity  = account.BillingCity;
                       con.MailingStreet = account.BillingStreet;
                    contactList.add(con);
                //}
                }
         update contactList;
    }
}
Trigger Code:
trigger IFAddrChangedUpdateContact on Account (after Update) {
    List<Id> contactIds = new List<Id>();
    List<Id> accountIds = new List<Id>();
    for(Account acc: Trigger.New){
    for(Contact con : acc.Contacts){
          contactIds.add(con.id);
    }
    }
    UpdateContactAddress obj = new UpdateContactAddress();
        obj.updateContact(contactIds);
}
Test Method:
@isTest
public class TestUpdateContactAddress {
    @isTest static void TestupdateContact() {
        Test.startTest();
        Account Acc1 = new Account(Name = 'Acc1 by Test',BillingCity = 'Chennai',BillingStreet = 'Lakeview Street');
        insert Acc1;
         Account Acc2 = new Account(Name = 'Acc2 by Test',BillingCity = 'Chennai',BillingStreet = 'Lakeview Street');
        insert Acc2;
        Contact con1 = new Contact(LastName='Contact created using test1', AccountId=Acc1.Id);
        Contact con2 = new Contact(LastName='Contact created using test2', AccountId=Acc1.Id);
        insert con2;
        insert con1;
         Contact con3 = new Contact(LastName='Contact created using test1', AccountId=Acc2.Id);
        Contact con4 = new Contact(LastName='Contact created using test2', AccountId=Acc2.Id);
        insert con3;
        insert con4;
        Account account1 = [Select Id,BillingCity,(SELECT ID from Contacts) from Account Where id =: Acc1.Id];
        account1.BillingCity='Vellore';
        update account1;
        Account account2 = [Select Id,BillingCity,(SELECT ID from Contacts) from Account Where id =: Acc1.Id];
        account2.BillingCity='Bangalore City';
        update account2;
        Test.stopTest();
    }
}
 

In the trigger code, I got only 85% code coverage and my apex class covered 100%. It shows,  contactIds.add(con.id);  this line is not covered.Please help me to cover my trigger code to 100%.