function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SimplySfdcSimplySfdc 

how to check custom field and object

Hi,

Is there anyway to check if a custom field and custom object is exist in an salesforce.com instance?
Is it possible to use Metadata WSDL for this?

I understand I can use partner wsdl using query and if a field / object is not exist will throw error, but i think this is not elegance.
Please advise and thanks.

Sq
SuperfellSuperfell
see the describeGlobal/describeSObject calls
sfdev1sfdev1
I recommend that you download the apex explorer
Mohd SarfrazMohd Sarfraz
Hi SimplySFDC,

for custom object ---->
Schema.getGlobalDescribe().get(objectName).getDescribe().isCustom();    retrun true if API name of custom object.

for custom fields----> 
     for(SobjectField fieldApi : Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap().values()){
         if(fieldApi.getDescribe().isCustom())
            // get true
     }

Thanks,
Sarfraz