You need to sign in to do that
Don't have an account?

how to get the filed names of sobject that we queried
hi everyone,
I would like to get the filed values of that we queried...below i would get the schema.sobjectfileds...
i have related object fileds in my query like account.name,account.type,account.industroy ,name,id from contact.
I would like store only above files and i wold like get the vaues respectively using schema.SobjectField
private void discoverAccessibleFields(sObject newObj) {
32 list< Schema.SobjectField> accessibleScheama = new List< Schema.SobjectField>();
33 Map<String, Schema.SobjectField> fields =
34 newObj.getSObjectType().getDescribe().fields.getMap();
35 for ( Schema.SobjectField s : fields.values()) {
36 accessibleScheama .add(a)
38 }
39 }
40 }
I would like to get the filed values of that we queried...below i would get the schema.sobjectfileds...
i have related object fileds in my query like account.name,account.type,account.industroy ,name,id from contact.
I would like store only above files and i wold like get the vaues respectively using schema.SobjectField
private void discoverAccessibleFields(sObject newObj) {
32 list< Schema.SobjectField> accessibleScheama = new List< Schema.SobjectField>();
33 Map<String, Schema.SobjectField> fields =
34 newObj.getSObjectType().getDescribe().fields.getMap();
35 for ( Schema.SobjectField s : fields.values()) {
36 accessibleScheama .add(a)
38 }
39 }
40 }
You can refer below sample code.
Refer below link.
https://blog.jeffdouglas.com/2011/10/20/getting-salesforce-field-metadata-the-easy-way/
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
Best Regards
Sandhya
https://bit.ly/2DvJbs9
I have a followup question to this. How do I use the sobject field to access the value from a contactMap. I have field name saved in a meta data and I want to use it in apex class. But I get the error variable does not exist. when I write this.
newmap.get(id).sobjectfield.