I'm trying to set the country field on the Address object on a Lead. However when I try to do:

mylead.address = my_country_string

It returns the error in the title of this question.

Illegal assignment from String to System.Address

If I try to do:

mylead.adddress.country = my_country_string

It returns the error

Invalid foreign key relationship: Lead.Address at line 55 column 13

How do I set the country field of the address object on a Lead if I already have a lead?

1 Answer 1


The compound form of the address. Read-only. See Address Compound Fields for details on compound address fields.


Address is a compound field, above is documentation for compound fields

Below is Lead Object documentation showing Country for the field on lead


Country: Country for the address of the lead

You should be using lead.Country

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.