1

When i am trying to update any standard field, it is working:

MetadataService.CustomField customField = new MetadataService.CustomField();
customField.fullName = 'Account.phone';
customField.label = 'testing';
List<MetadataService.SaveResult> results = service.updateMetadata(new MetadataService.Metadata[] { customField });

But when i try to update a custom field, it throws an error, asking to give additional parameters (like, type, length if its a Text type field):

MetadataService.CustomField customField = new MetadataService.CustomField();
customField.fullName = 'Account.Active__c';
customField.label = 'testing';
List<MetadataService.SaveResult> results = service.updateMetadata(new MetadataService.Metadata[] { customField });

What am I doing wrong here ? Any help would be appreciated.

Thanks @Keith, I tried readmetadata also, but I am getting null in the result.

MetadataService.IReadResult test = service.readMetadata('CustomField', new String[] { 'Account.Active__c'});
customField = (MetadataService.CustomField)test.getRecords()[0];
customField.label = 'testing';
List<MetadataService.SaveResult> results = service.updateMetadata(new MetadataService.Metadata[] { customField });

When i try to debug test.getRecords()[0] -- its attributes like :

records=(CustomField:[Metadata.fullName=null, apex_schema_type_info=(http://soap.sforce.com/2006/04/metadata, true, false), caseSensitive=null,

an so on..

2
  • 1
    Suggest you readMetadata, modify, then updateMetadata to work around the problem.
    – Keith C
    Jun 27, 2016 at 15:52
  • 1
    @KeithC - Please see updated question.. I also tried readMetadata..but didnt work Jun 27, 2016 at 16:45

1 Answer 1

0

Standard fields don't have much metadata, usually just the fullname and type. Even standard picklist values are pretty sparse.

Custom fields however have lots of metadata and you must have that information for an update. You mentioned the length parameter for a text field. Yep, you need all that stuff.

The metadata channel does not merge Custom Fields they are asset types and you need all the parameters. Hope that helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .