• Mukund
  • NEWBIE
  • 0 Points
  • Member since 2012

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

I am   trying to update the  metadata  of managed  Application's  custom  Object using Metadata API .

I created  appex class using metadata wsdl  by  doing  some  channges in  wsdl file .

Now I am facing  issue in using create method of generated class .

create(soapSforceCom200604Metadata.Metadata[] metadata); 

Do  i need to get the metadata in Zip file and then update metadata and again deploy the updated metadata .

What is the complete step to update the metadata of managed custom Object .

Regards

Mukund

Hi all,

 

I can successfully connect to the Metadata API and create a custom field, but what I would like to do is create three custom fields all at the same time. From reading the Metadata specifications it appears I can provide the .create() method with up to 10 metadata components, so technically I should be able to pass it an array of 3 custom fields instead of a single custom field, and it should process them all with only one .create() call.

 

My code to create one custom field is as follows:

 

SFMetadataWSDL.CustomField customField = new SFMetadataWSDL.CustomField();

 

customField.fullName = "Account.TestField__c";

customField.description = "This is a custom field created by the API";

customField.label = "Test Field;

customField.formula = "HYPERLINK(\"http://www.cnet.com\", \"Open Cnet\")";

customField.type = SFMetadataWSDL.FieldType.Text;

 

SFMetadataWSDL.AsyncResult asyncResult = sfMetadata.create(new SFMetadataWSDL.Metadata[] { customField })[0];

 

This works just fine, but if I modify it to pass the .create() method an array of 3 custom fields, I cannot compile.

 

SFMetadataWSDL.CustomField[] customField = new SFMetadataWSDL.CustomField[3];

 

customField[0].fullName = "Account.Testfield1__c";

customField[0].description = "This is a custom field number 1 created by the API";

customField[0].label = "Test Field 1";

customField[0].formula = "HYPERLINK(\"http://www.cnet.com\", \"Open Cnet\")";

customField[0].type = SFMetadataWSDL.FieldType.Text;

 

customField[1].fullName = "Account.Testfield2__c";

customField[1].description = "This is a custom field number 2 created by the API";

customField[1].label = "Test Field 2";

customField[1].formula = "HYPERLINK(\"http://www.cnet.com\", \"Open Cnet\")";

customField[1].type = SFMetadataWSDL.FieldType.Text;

 

customField[2].fullName = "Account.Testfield3__c";

customField[2].description = "This is a custom field number 3 created by the API";

customField[2].label = "Test Field 3";

customField[2].formula = "HYPERLINK(\"http://www.cnet.com\", \"Open Cnet\")";

customField[2].type = SFMetadataWSDL.FieldType.Text;

 

SFMetadataWSDL.AsyncResult[] asyncResult = sfMetadata.create(new SFMetadataWSDL.Metadata[] { customField });

 

The compilation error I receive is "Cannot implicitly convert type 'SFMetadataWSDL.CustomField[]' to 'SFMetadataWSDL.Metadata'". I think I'm being an idiot here and have just missed something out - can someone point it out?

 

Thanks

Matt 

  • January 20, 2010
  • Like
  • 0