In my contact object, I have a field name as "otheraddress"

From the apex code, I am first getting the field value and if it is null then I am modifying the value of the field.

getting first the contact object from the list of contact

Contact contact = contactList[0];
Object value  = contact.get('otheraddress');
if(value == null){

I can get the field value with no error and while at the time updating it I am getting an error: Invalid field otheraddress for Contact


1 Answer 1


Thanks for @Kurunve's comment to pointing out that this is a compound field in Contact.

Following this post (special thanks to @dzh)

I ran the class and obtained the field name for OtherAddress field in Contact object.

One way you can modify the value for the OtherAddress is by manually assigning the values for each field you want for example:

contact.OtherStreet = updatedStreet;
contact.OtherCity = updatedCity;

you could also do it your way if you prefer

contact.put('OtherStreet', updatedValue);

and so on, of course you can optimise this code further, but I will leave it up to here first.

You must log in to answer this question.

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