1

as I writing a test class, I come across this error as I am attempting to save my file.

Error: Compile Error: Illegal assignment from String to Boolean at line 15 column 13

Are there any adjustments, I need to make to my code.

Many Thanks

@isTest 
public class ContactLookupControlTest 
{
    static testMethod void validateContactLookupControl() 
    {
            Contact c = new Contact();
            c.FirstName = 'Paul';
            c.LastName = 'Reid';
            c.MailingStreet = '205 Hill Street';
            c.MailingCity = 'Los Angeles';
            c.MailingState = 'CA';
            c.MailingPostalCode = '90015';
            c.Email = '[email protected]';
            c.HOC__Registration_Status__c = 'Not Registered';
            c.Volunteer__c = 'FALSE';
            c.npe01__Type_of_Account__c = 'Individual';
            c.HOC__Minor_Wavier_on_File__c = 'FALSE';
            c.HOC__HOC_Domain_Name__c = 'http://operationgratitude.force.com';
            c.HOC__Disabled_Person__c = 'FALSE';
            c.HOC__Calculated_Birthdate__c = 'FALSE';
            c.HOC__Confirmed_Organizer__c = 'FALSE';
            c.HOC__Number_of_Contacts__c = '1.0';
            insert c;

            Test.StartTest(); 

                PageReference pageRef = Page.ContactLookupControl; // Add your VF page Name here
                pageRef.getParameters().put('lksrch', 'Paul');

                ContactLookupControl obj = new ContactLookupControl();
                obj.contact.FirstName ='Test';
                obj.contact.LastName ='TestLast';
                obj.saveContact();
                String str = obj.getFormTag();

            Test.StopTest();
    }
}

2 Answers 2

2

Change

c.Volunteer__c = 'FALSE';
c.HOC__Minor_Wavier_on_File__c = 'FALSE';
c.HOC__Disabled_Person__c = 'FALSE';
c.HOC__Calculated_Birthdate__c = 'FALSE';
c.HOC__Confirmed_Organizer__c = 'FALSE';

to

c.Volunteer__c = false;
c.HOC__Minor_Wavier_on_File__c = false;
c.HOC__Disabled_Person__c = false;
c.HOC__Calculated_Birthdate__c = false;
c.HOC__Confirmed_Organizer__c = false;
1
  • @MedhanieHabte - If this solves your issue please mark the question as answered so it does not keep getting bumped by the system.
    – Eric
    Commented Jun 22, 2015 at 0:56
3

Line 15 should be

c.Volunteer__c = false;

without quotes. It seems like it's a boolean field and you're assigning a string to it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .