You need to sign in to do that
Don't have an account?
Rahul Sangwan7341
how to Access custom field in sObjectList
I faced this issue quite oftenly.
//sObj will be the API name come dynamically based on parameters String query = 'Select Id, C_Location__c from '+sObj; List<sObject> sObjList = new List<sObject>(); try{ sObjList = Database.query(query); }catch(Exception e){ system.debug('Exception:::::::::'+e.getMessage()); } if(sObjList.size() > 0){ for(sObject sObjRet : sObjList){ //now where if we want to access any other field than standard fields of that object it throws error AllRecordsWrapper wrapperObj = new AllRecordsWrapper(sObj , sObjRet.Id, sObjRet); wrapperList.add(wrapperObj);
Please use below below syntax to get fields from sObject :
sObjRet.get('Id'); //In arguement pass the name of filed which you want to access.
You can find more help in working with Sobjects in link given below :
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm
Let me know if you need more help.
Regards,
Abhishek
All Answers
Please use below below syntax to get fields from sObject :
sObjRet.get('Id'); //In arguement pass the name of filed which you want to access.
You can find more help in working with Sobjects in link given below :
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm
Let me know if you need more help.
Regards,
Abhishek