You need to sign in to do that
Don't have an account?
sonu
regarding sObject
hi,
please find the below lines of code
sObject s=new Account[select id,name from Account where name like 'test%'];
ID i=s.id;//valid
String name=s.name//invalid
please correct me if i am wrong, why the second statement is invalid and first statement is valid because as far as i knows that sObject holds the state and behaviour of all the concrete objects here sObject is generic object and Account object is concrete object.
please provide the detailed solution that why we can not access the id field using sObject reference i.e 's'
Thanks in advance
Hi,
sObject type allows get only Id field with dot notation, because all objects which can be assigned to sObject type has Id field. You must use the get(field_name) method of sObject for retrieving needed field.
Try this:
String name=s.get('name');
or
String name = ((Account)s).Name;