0

我有以下代码...但是当我通过元数据 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;
4

1 回答 1

-1

这是不可能的,您必须采取手动步骤来激活插入的选项列表值

于 2019-02-21T07:51:11.843 回答