I have an address field which has some value and I need to convert address to string and store it in a text area field.

when i did


its returning

system.Address[getCity=Columbia;getCountry=null;getCountryCode=null;getPostalCode=22036;getState=MD;getStateCode=null;getStreet=1505 21st Street NW;]

I just need to get the address as it appears in shipping address field. How can I serialise it to a string?


Though billing address appears as one field on the UI it is a compound of multiple text fields

You can do

account a = [select id,billingstreet,billingcity,billingstate,billingPostalCode,BillingCountry from account where id=:'001d000001hKINv'];
string shippingAddress = a.billingstreet+ a.billingcity + a.billingstate + a.billingPostalCode+ a.BillingCountry;

Refer: https://www.salesforce.com/developer/docs/api/Content/compound_fields_address.htm

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.