5

I am trying to update the record type to move the picklist values to the 'active values' . I am using the metadata api. Below is my code where Scope_Of_Services_Tasks__c is the name of object , Meeting_Type__c is the field name and Project_Management is the name of the Record type :-

MetadataService.RecordType rt = new MetadataService.RecordType();
rt.active = true;
rt.fullName = 'Project_Management';
rt.label = 'Project Management';
MetadataService.PicklistValue pv = new MetadataService.PicklistValue();
pv.fullName = 'test123';

MetadataService.RecordTypePicklistValue ohmVersions = new MetadataService.RecordTypePicklistValue();
ohmVersions.Picklist = 'Meeting_Type__c';
ohmVersions.values = new MetadataService.PicklistValue[] { pv };
rt.PicklistValues = new MetadataService.RecordTypePicklistValue[] { ohmVersions };


return handleSaveResults(
    service.updateMetadata(
        new MetadataService.Metadata[] { rt })[0]);   

The code is giving this error :- "Web service callout failed: WebService returned a SOAP Fault: '' is not valid for type xsd:boolean, should be '0', '1', 'true' or 'false' faultcode=soapenv:Client faultactor="

PLease help me out as this is very urgent and I am trying since more than 2 days. Thanks

Update:- pv.fullName = 'test123'; here 'test123' is the picklist value that need to be moved to the active values in the record type picklist.

7
  • does : pv.default_x = false; help?
    – cropredy
    Feb 4, 2015 at 2:31
  • Nope...Still same error Feb 4, 2015 at 2:33
  • Do you read the RecordType first before updating it? Although my use of the wrapper is for updating PicklistValues on CustomField, I read the CustomField first before doing the update. Otherwise, you'll smash whatever was there beforehand.
    – cropredy
    Feb 4, 2015 at 2:47
  • Actually this is the only I am doing that I have posted Feb 4, 2015 at 2:54
  • I can only say that when I used the metadata API to update a picklist, I first used readData to fetch the metadata object, updated in apex the various objects deserialized by the readData and then used update as you show above. This ensures that all fields are set to values as they were in SFDC and one only changes the object.field values as needed. I carefully looked at the example code in the apex wrapper to the metadata api package
    – cropredy
    Feb 4, 2015 at 6:46

2 Answers 2

1

Here is your issue

I'm presuming you are using the Apex wrapper to the metadata API as found here

  1. In order to use the service.updateMetadata(..) method, you first need to use the readMetaData(..) method for the metadata object you intend to update. In your case, this is the MetadataService.RecordType
  2. The Apex Metadata API wrapper will take the JSON response from the Metadata API and deserialize into the various MetadataService wrapper classes that represent the MetaDataService.RecordType and its child object collections
  3. All of the wrapper class fields will be properly populated to mirror what is in SFDC. Hence, all of the Boolean fields will have values.
  4. You then need to modify the datastructure, taking care not to smash lists of existing values to add the new picklist item to an existing recordType's picklist of interest.
  5. Finally, you can do the updateMetaData(..)

A close relevant example provided in class MetadataServiceExamples is method updatePicklist() where you can see the readMetaData(..) call preceding the updateMetadata() call.

0

Web service callout failed: WebService returned a SOAP Fault: '' is not valid for type xsd:boolean, should be '0', '1', 'true' or 'false' faultcode=soapenv:Client faultactor=

means that you have a required Boolean set as null. That Boolean needs to be either true or false.

You must log in to answer this question.

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