1

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?

3

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

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/compound_fields_address.htm

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

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

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_lead.htm

Country: Country for the address of the lead

You should be using lead.Country

| improve this answer | |

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.