0
votes

I need to read all custom fields from Opportunity object using apex , how is that possible ?

2

2 Answers

1
votes
public Map<String, Schema.SObjectField> M = Schema.SObjectType.Opportunity.fields.getMap();

fieldSet = M.keySet();

fieldSet is a set of all fields as string, Either use it directly in the query or loop over it and prepare a string and use that in the query with Database.query

However note that it would consist of fields which are in Opportunity not of the relationship specific fields

0
votes

Its not generally good practice to query all fields, especially objects in the cloud, in not good for speed and efficiency. Can you not just specify the fields you want?

try the Salesforce describe method to loop or get fields if you cant specify:

describe methods