List addCustomFieldToWorksheet() {
    List defaultFields =
        NliFieldDefinitionServiceProxy.getInstance()
            .findAllMandatoryFieldsByClassType(getClassType());

    // remove coded fields from default field list
    //        if(holdingWorksheetDefinition.isSimpleWorksheet()){
    //	        defaultFields.removeAll(getCodedFields());
    //		}

    boolean addingDefaultFieldMustBeChecked = false;
    HoldingCustomFieldDefinition customFieldDefinition;
    if (holdingWorksheetDefinition.getCustomFieldList().isEmpty()) {
      for (int i = 0; i < defaultFields.size(); i++) {
        customFieldDefinition =
            new HoldingCustomFieldDefinition((HoldingFieldDefinition) defaultFields.get(i));
        customFieldDefinition.setWorksheetDefinition(holdingWorksheetDefinition);
        holdingWorksheetDefinition.getCustomFieldList().add(customFieldDefinition);
      }
      addingDefaultFieldMustBeChecked = true;
    }

    List selectedFields = grid.getSelectedRecords();
    List castedField4NextStep = new ArrayList();
    if (selectedFields.size() == 0) selectedFields = grid.getCheckedRows();

    if (addingDefaultFieldMustBeChecked) {
      for (int i = 0; i < selectedFields.size(); i++) {
        WorksheetFieldRowData worksheetFieldRowData = (WorksheetFieldRowData) selectedFields.get(i);
        CustomFieldDefinition customFieldDefinition1 =
            new HoldingCustomFieldDefinition(
                (HoldingFieldDefinition) worksheetFieldRowData.getFieldDefinition());
        customFieldDefinition1.setWorksheetDefinition(holdingWorksheetDefinition);
        if (!holdingWorksheetDefinition.getCustomFieldList().contains(customFieldDefinition1)) {
          holdingWorksheetDefinition.addCustomField(customFieldDefinition1);
          castedField4NextStep.add(customFieldDefinition1);
        }
      }
    } else {
      for (int i = 0; i < selectedFields.size(); i++) {
        WorksheetFieldRowData worksheetFieldRowData = (WorksheetFieldRowData) selectedFields.get(i);
        CustomFieldDefinition customFieldDefinition1 =
            new HoldingCustomFieldDefinition(
                (HoldingFieldDefinition) worksheetFieldRowData.getFieldDefinition());
        customFieldDefinition1.setWorksheetDefinition(holdingWorksheetDefinition);
        holdingWorksheetDefinition.addCustomField(customFieldDefinition1);
        castedField4NextStep.add(customFieldDefinition1);
      }
    }
    return castedField4NextStep;
  }
 @Override
 List<FieldDefinition> getCodedFields() {
   return NliFieldDefinitionServiceProxy.getInstance()
       .findAllCodedField(HoldingCodedItemsDefinition.class);
 }