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

You must log in to answer this question.

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