我有以下代码...但是当我通过元数据api将多个值插入选项列表字段时,将插入所有值,但作为不活动值,仅将最后一个值插入为活动值,而该最后一个活动值将所有先前值设为无效。请提供帮助。
MetadataService.CustomObject customObj;
customObj = new MetadataService.CustomObject();
MetadataService.MetadataPort service = createService();
MetadataService.CustomField customField = new MetadataService.CustomField();
customField.fullName = objectName +'.'+ fieldName;
customField.label = fieldLabel;
customField.type_x = fieldType;
//Create the valueSet for picklist type
MetadataService.ValueSet picklistValueSet = new MetadataService.ValueSet();
//For each ValueSet, we have either ValueSetValuesDefinition or ValueSettings and some other attributes
MetadataService.ValueSetValuesDefinition valueDefinition = new MetadataService.ValueSetValuesDefinition();
List<MetadataService.CustomValue> values = new List<MetadataService.CustomValue>();
MetadataService.CustomValue customValue1 = new MetadataService.CustomValue();
//Adding "Default" value as one picklist value in the newly created picklist
customValue1.fullName = valFullName ;
customValue1.description = '';
customValue1.isActive =TRUE;
customValue1.default_x = FALSE;
customValue1.label = valLabel;
values.add(customValue1);
//It will be list of CustomValue
valueDefinition.value = values;
valueDefinition.sorted = false;
//set the valueSetDefinition
picklistValueSet.valueSetDefinition = valueDefinition;
//Set the valueSet for picklist type
customField.valueSet = picklistValueSet;
答案 0 :(得分:-1)
那是不可能的,您必须采取手动步骤来激活插入的选择列表值