You need to sign in to do that
Don't have an account?
davidesi
Get Whole object through its id
I want to get all the fields of an object.
Is there any way to get the whole object? Or I need to write the full query? My object has more than 200 fields (I can write them copying and pasting, but if exists another way ...
Thanks
There is no select * here. So I'm afraid you have to write all those if you want in static query.
If you are prepared to use dynamic query then, you can fetch all the fields of the particular object by using Sobject methods and perform a string of those and then use them in the dynamic soql query.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
All Answers
In the first case you would have to write the names each of the field. However, please note there is a limit to the number of characters of a query.
If you would like to get the names of the fields in the object you could use Describe calls.
Hope this helps.
Regards,
Satish Kumar
Something like that:
Opportunity op = (Opportunity) ApexPages.StandardController stdController.getRecord();
Then, is it impossible?
Should I query all the fields which I want to obtain?
Opportunity op = [SELECT ANEG__c, Account_State__c, Activity_Performed_in_Port__c, Administrative_Contact_Email__c, Administrative_Contact_Last_Name__c, Administrative_Contact_Phone__c, Administrative_Contact_First_Name__c, Accesed_Airports__c, Commercial_Adjust__c, Technical_Adjust__c, Ampliaci_n__c, Extension__c, Anulaci_n_por_impago__c, Surname__c, Current_Insurer__c, Assistance__c, FiscalYear, Business_Contact_Email__c, Business_Contact_Last_Name__c, Business_Contact_Phone__c, Account_TIN__c, Existing__c, Campa_a_hasta__c, Campo_usuario_Lanzadera__c, Campo_usuario_URL__c, Channel__c, TotalOpportunityQuantity, Production_N_Amount__c, Portfolio_Amount__c, Principal__c, Maximum_Principal__c, Minium_Principal__c, Position__c, ForecastCategory, ForecastCategoryName, IsClosed, Cif_Cuenta_Padre__c, City__c, Ciudad__c, Codigo_ANEG_Cuenta__c, Codigo_ANEG_Filial__c, [...] FROM Opportunity
Thanks,
David Herrero
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
There is no select * here. So I'm afraid you have to write all those if you want in static query.
If you are prepared to use dynamic query then, you can fetch all the fields of the particular object by using Sobject methods and perform a string of those and then use them in the dynamic soql query.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Thank you for your help
Hi,
This can be achieved by creating Fieldsets for that object.
You are having 200 fields. So, create a Fieldset for that object and drag the fields you want to query.
Now querying all those 200 fields becomes easier.
To create a field set follow the steps below,
For your reference, please a take a look on the following link,
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_fieldsets_describe.htm
Dont forget to give kudos and mark this answer as a solution, if this answer works out..