• Bhaskar2013
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

I am working on Metadata API to develop Webservices for Custom Object management.

 

Here is part of  the code, which accepts a  string of object name and gets all the fileds. The line-2 of the code is not working.

 

So I had to get all the objects in Schema, looping through them and get matching object type of what I require.

But is there an efficient way of doing the same? Please help me.

==================

 

String sObjectName='MyCustomObject__c';

//Schema.SObjectType targetType = Schema.getGlobalDescribe().get(sObjectName); //This is returning null

List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();

Schema.SObjectType objToken;

for(Schema.SObjectType obj: gd){        

    if(Obj.getDescribe().getName().toLowerCase()==sObjectName.toLowerCase()){   

         objToken=obj;            

         break;           

    }

 }

Schema.DescribeSObjectResult typedescription = objToken.getDescribe();

 

//...Now I can continue working with my object  field changes

I am working on Metadata API to develop Webservices for Custom Object management.

 

Here is part of  the code, which accepts a  string of object name and gets all the fileds. The line-2 of the code is not working.

 

So I had to get all the objects in Schema, looping through them and get matching object type of what I require.

But is there an efficient way of doing the same? Please help me.

==================

 

String sObjectName='MyCustomObject__c';

//Schema.SObjectType targetType = Schema.getGlobalDescribe().get(sObjectName); //This is returning null

List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();

Schema.SObjectType objToken;

for(Schema.SObjectType obj: gd){        

    if(Obj.getDescribe().getName().toLowerCase()==sObjectName.toLowerCase()){   

         objToken=obj;            

         break;           

    }

 }

Schema.DescribeSObjectResult typedescription = objToken.getDescribe();

 

//...Now I can continue working with my object  field changes

Hi All,

 

I have two questions.

 

  1. I want to find whether the object is in our organization or not. I want to do this in APEX controller. Is there any method to do that?
  2. After find the object I want to retrieve the fields name of that object. This also want to perform in APEX controller. Is there any method to do that? 

Thanks in Advance!

 

 

Hi All,

 

I am using the Metadata API to add custom fields to a custom object.

 

The custom fields created should be identical in terms of field type to existing standard or custom fields in other standard or custom objects. For instance, I need to create a custom field that is of the same type as the Account Shipping Street.

 

The Account.ShippingStreet in salesforce is of type: textarea and length 255

 

When using the Metadata API to create a custom field of the same type, the field created ends up being of type: string and length 255, instead of type textarea.

 

I am using the deploy() method of the Metadata API so I create the package.xml file on the fly and deploy it. The <type> element in the file is textarea, and the <length> is 255.

 

Any ideas what I am missing here would be much appreciated.

 

Fernando