Open CedricWillems opened 6 years ago
Can you run this via Developer Console exec anonymous and post the XML shown in the debug log? This also helps narrow the issue down to a Metadata API issue or an issue with this lib.
I came across the exact same error when I tried to use the updateMetadata call to add a picklist value to an existing field. It seems like it's due to the following line in MetadataService.cls : https://github.com/financialforcedev/apex-mdapi/blob/08656f19002124d841e797fbd37d5a7ee8aa5678/apex-mdapi/src/classes/MetadataService.cls#L1411 The 'color' attribute of CustomValue is not described as optional while the Metadata WDSL describes it as such :
<xsd:complexType name="CustomValue">
<xsd:complexContent>
<xsd:extension base="tns:Metadata">
<xsd:sequence>
<xsd:element name="color" minOccurs="0" type="xsd:string"/>
<xsd:element name="default" type="xsd:boolean"/>
<xsd:element name="description" minOccurs="0" type="xsd:string"/>
<xsd:element name="isActive" minOccurs="0" type="xsd:boolean"/>
<xsd:element name="label" minOccurs="0" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
The following adjustment resolved the issue :
private String[] color_type_info = new String[]{'color','http://soap.sforce.com/2006/04/metadata',null,'0','1','false'};
Yes this looks like a bug in the Salesforce WSDL is the root cause.
Hi,
I am executing below code in Dev Console.Code is executing without any error, but Global picklist is not getting created.
any suggestion? `MetadataService.MetadataPort service = new MetadataService.MetadataPort(); service.SessionHeader = new MetadataService.SessionHeader_element(); service.SessionHeader.sessionId = UserInfo.getSessionId();
String valueSetName = 'test123';
MetadataService.GlobalValueSet globalValueSet = new MetadataService.GlobalValueSet();
MetadataService.CustomValue newItem = new MetadataService.CustomValue(); newItem.fullName = 'value'; newItem.label = 'label'; newItem.isActive = true; newItem.default_x = true;
if(globalValueSet.customValue ==null){
globalValueSet.customValue = new List
globalValueSet.customValue.add(newItem);
globalValueSet.masterLabel='test123'; globalValueSet.sorted=false; globalValueSet.description='sd'; service.createMetadata( new MetadataService.Metadata[]{ globalValueSet }); `
and
errors =null and success =false from saveResult
Class Example:
Anonymous Apex:
'default' and 'isActive' are 'null', so these are giving an error aswell.